#include <stdio.h>
#include<stdlib.h>
int main()
{
int N;
while(scanf("%d",&N)!=EOF)
{
int i,a;
long long int b,c;
for(i=0;i<N;i++)
{
scanf("%d %d %d",&a,&b,&c);
switch(a)
{
case 1:
printf("%d\n",b+c);
break;
case 2:
printf("%d\n",b-c);
break;
case 3:
printf("%d\n",b*c);
break;
case 4:
printf("%d\n",b/c);
break;
}
}
}
return 0;
}
=========================================
一開始用int時沒有錯 但是會overflow
改用long long int 後,b/c卻會錯誤
會甚麼會這樣哩??
#include
#include
int main()
{
int N;
while(scanf("%d",&N)!=EOF)
{
int i,a;
long long int b,c;
for(i=0;i {
scanf("%d %d %d",&a,&b,&c);
switch(a)
{
case 1:
printf("%d\n",b+c);
break;
case 2:
printf("%d\n",b-c);
break;
case 3:
printf("%d\n",b*c);
break;
case 4:
printf("%d\n",b/c);
break;
}
}
}
return 0;
}
=========================================
一開始用int時沒有錯 但是會overflow
改用long long int 後,b/c卻會錯誤
會甚麼會這樣哩??