Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Compile Error 因为变量没放在代码前而报错

Posted by 1506300007 at 2016-04-04 20:01:37 on Problem 1331
```/*
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: