C scanf读入longlong型数据的问题

codeup上很水的题目,但是第一次提交报错了 http://codeup.cn/problem.php?cid=100000575&pid=1
检查了一下输入为符号的情况,发现用longlong型直接用%d读入的话会不识别负号,用cin或者%lld就没问题

#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int num;
    scanf("%d",&num);
    long long int A,B,C;
//  int A,B,C;
    int j=1;
    for(int i=0;i<num;i++)
    {
        //应用%lld, %d会不识别负号
        scanf("%lld%lld%lld",&A,&B,&C);
        //cin没问题
    //  cin>>A>>B>>C;
        if(A+B>C) 
        {
            printf("Case #%d: true\n",j++);
        }
        else
        {
            printf("Case #%d: false\n",j++);        
        }
    }

猜你喜欢

转载自blog.csdn.net/hhmy77/article/details/82429260