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 |
Compile Error 因为变量没放在代码前而报错/* F:\temp\15353018.46551\Main.c(10) : error C2143 : syntax error : missing ';' before 'type' 变量声明要放在其它代码之前 F : \temp\15353018.46551\Main.c(11) : error C2065 : 'len' : undeclared identifier */ #include<stdio.h> #include<string.h> int jinzhi(int x, int jin){ char arr[50]; int shu = 0; int i,len; sprintf(arr, "%d", x); len = strlen(arr);//原代码是写成 int len=strlen(arr) 不能AC,错因可见上方 for ( i = 0; i < len; i++) { if (arr[i] - '0' >= jin) return -1; shu *= jin; shu += arr[i] - '0';//421(5) i=2第三次 shu=(4*5+2)*5+1 } return shu; } int main(){ int t, p, q, r; int i; scanf("%d", &t); while (t--){ scanf("%d%d%d", &p, &q, &r); for (i = 2; i <= 16; i++){ int p2 = jinzhi(p, i); int q2 = jinzhi(q, i); int r2 = jinzhi(r, i); if (p2 == -1 || q2 == -1 || r2 == -1) continue; if (p2*q2 == r2){ printf("%d\n", i); break; } //此处,p2、q2、r2为十进制数 ,用来判断“p*q=r”是否成立 } if (i == 17) printf("0\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator