认真读题:B中可能包含空格所以B不能用scanf来读取!!!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int IsStanderd( char *A);
int main(){
char A[20];
char B[20];
scanf("%s",A);
getchar(); //这里必须加一个来读取空格,不然getchar读到缓冲区第一位就是空格
gets(B); //测试点3就是说第一个空格之后的是第二个B,所以B中野可能出现空格.要认真读题干,没有认真读题干在测试点3上卡了半天
int a = atoi(A);
int b = atoi(B);
if(IsStanderd(A)==0||IsStanderd(B)==0){ //不标准
if(IsStanderd(A)==0&&IsStanderd(B)==0){
printf("? + ? = ?");
return 0;
}else if(IsStanderd(A)==0){
printf("? + %d = ?",b);
return 0;
}else{
printf("%d + ? = ?",a);
return 0;
}
}else{//标准的
int c = a+b;
printf("%d + %d = %d",a,b,c);
}
return 0;
}
int IsStanderd( char *A){
int a = atoi(A);
int i;
for(i=0;i<strlen(A);i++){
if(A[i]<'0'||A[i]>'9'){
return 0;
}
}
if(a<1||a>1000){
return 0;
}
return 1; //标准的
}