<分区>
这是我的代码,请帮帮我,百分比显示 0.00 而不是我想要的。
我想计算百分比,你会通过下面的代码知道这一点......
#include<stdio.h>
#include<conio.h>
int main()
{
int marks[2][3]={80,70,50,90,50,60};
int total[2]={0,0};
float per[2]={0.0f,0.0f};
for (int x=0;x<2;x++)
{
for(int y=0;y<3;y++)
{
printf("[%d][%d]=%d\t",x,y,marks[x][y]);
total[x]=total[x]+marks[x][y];
per[x]=total[x]/300*100;
}
printf("total [%d]=%d",x,total[x]);
printf("\n\npercentage [%d]=%2.2f \n",x,per[x]);
putchar('\n');
}
getch();
return 0;
}