以下為我的程式碼:
#include <iostream>
#include <string.h>
#include <cstdlib>
using namespace std;
int main(int argc, char** argv) {
char k[1000001] , *p;
int t;
long long int ans;
scanf("%d",&t);
getchar();
while(t--) {
ans=0;
cin.getline(k,1000000);
p=strtok(k," ");
while(p) {
if(p!="+") ans+=atoi(p);
p=strtok(NULL," ");
}
printf("%lld\n",ans);
}
return 0;
}
在測試時他說我的答案為0
但送上去時卻AC