请问为啥C用long int 反而WA呢?

P1001 A+B Problem

Li_Hua_13 @ 2023-11-13 23:18:43

#include<stdio.h>
int main()
{
    long int a,b;
    scanf("%d %d",&a,&b);
    printf("%ld",a+b);
    return 0;
}

by LuoTianyi_Official @ 2023-11-13 23:28:25

输入?


by Jianbing_Juan @ 2023-11-14 00:32:44

读入的时候用 %ld .

最好学c++,用cin/cout不用考虑占位符的问题


by Li_Hua_13 @ 2023-11-14 10:06:35

@Jianbing_Juan 好的,谢谢您


by Li_Hua_13 @ 2023-11-14 10:06:57

@LuoTianyi_Official 谢谢您


by acaiji233 @ 2023-11-21 20:18:39

@Li_Hua_13 用c++的cin和cout就不会有问题了


by zengyijian @ 2023-12-09 14:48:04

这么写:

#include<iostream>
using namespace std;
int main(){
    long long a,b;
    cin>>a>>b;
    cout<<a+b;
    return 0;
}

by xiaobeichen @ 2023-12-14 12:56:19

scanf要用%ld


by CHkuakeU @ 2023-12-15 08:19:42

scanf不是用%d吗?


by hyh0174 @ 2023-12-15 21:54:38

@CHkuakeU %d输入整数型,%ld输入长整数型,还有%c,%s,%lld等等


by CHkuakeU @ 2023-12-17 08:19:48

@hyh0174 对于本题来说


|