作业帮 > 综合 > 作业

为什么这道题会WA描述Given N arithmetic expressions,can you tell whose

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/10 11:39:35
为什么这道题会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
#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;
}
//刚做完,仅供参考