| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请帮帮我看看为什么老师compiled error,答案都符合,晕#include "stdio.h" #include "string.h" #include "ctype.h" int reverse(char x[]); int itoa(int n, char s[]); int atoi(char s[]); int main() { int n; char s1[1000],s2[1000]; int k; scanf("%d",&n); while(n-- >0){ scanf("%s%s",s1,s2); reverse(s1); reverse(s2); k=atoi(s1) + atoi(s2); itoa(k,s1); k=atoi(s1); printf("%d\n",k); } return 0; } int reverse(char x[]) { int i,j; char a; for(i=0,j=strlen(x)-1;i<j;j--,i++){ a=x[i]; x[i]=x[j]; x[j]=a; } return 0; } int itoa(int n, char s[]) { int i; i = 0; do { /* generate digits in reverse order */ s[i++] = n % 10 + '0'; /* get next digit */ } while ((n /= 10) > 0); /* delete it */ s[i] = '\0'; return 0; } int atoi(char s[]) { int i, n, sign; for (i = 0; isspace(s[i]); i++) /* skip white space */ ; sign = (s[i] == ' ')? 1: 1; if (s[i] == '+' || s[i] == ' ')/* skip sign */ i++; for (n = 0; isdigit(s[i]); i++) n = 10 * n + (s[i] -'0'); return sign * n; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator