关于longlong的输⼊和输出
long long 在Codeblocks ⾥可以正常的输⼊和输出,但是在VC⾥⾯就出问题了,会出现:
binary '>>' : no operator defined which takes a right-hand operand of type '__int64' (or there is no acceptable conversion)的报错,并且关键字也不能写成long long的形式,这样也是会报错的,总之在VC⾥使⽤long long特别费劲
VC:
输出:printf("%I64d",s);
输⼊:scanf("%I64d",&l);
今天做⼀道⽔题⼜遇到问题了,由于蓝桥杯⽤的是DEV-C++,所以⼜⼀个编译器,就⼜产⽣问题了,⾸先
codeBlock中:
scanf("%lld",&n);
printf("%lld",sum);//long long输出
输⼊:scanf("%I64d",&l);
输出:printf("%I64d",s);
所以为了以后避免错误,就直接⽤这种⽅式就⾏了
题⽬代码:
codeblocks带编译器版本#include <stdio.h>
int main()
{
long long  sum = 0, n = 0;  //__int64  long long型
scanf("%lld",&n);
sum = (n+1)*n/2;/////这⾥听短⼩精悍的
printf("%lld",sum);//long long输出
return 0;
}