为什么这道题会WA描述Given N arithmetic expressions,can you tell whose result is closest to 输入Line 1:N (1
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/25 09:31:50
为什么这道题会WA描述Given N arithmetic expressions,can you tell whose result is closest to 输入Line 1:N (1
为什么这道题会WA
描述
Given N arithmetic expressions,can you tell whose result is closest to
输入
Line 1:N (1
为什么这道题会WA描述Given N arithmetic expressions,can you tell whose result is closest to 输入Line 1:N (1
#include
#include
#include
#include
int main()
{
int N=0,i=0,j=0,pa,pb;
int index =0;
\x05double sum=10;
char oper = '+';
double * res;
scanf("%d\n",&N);
res = (double *)malloc(N*8);
for(i=0;i res[i])?i:index;
sum = (sum > res[i])?res[i]:sum;
case '-':res[i]=abs((pa - pb)-9); index = (sum > res[i])?i:index;
sum = (sum > res[i])?res[i]:sum;
case '*':res[i]=abs((pa * pb)-9); index = (sum > res[i])?i:index;
sum = (sum > res[i])?res[i]:sum;
case '/':res[i]=fabs((pa*1.0 / pb)-9); index = (sum > res[i])?i:index;
sum = (sum > res[i])?res[i]:sum;
}
}
printf("%d\n",index+1);
return 0;
}
//刚做完,仅供参考