早教吧 育儿知识 作业答案 考试题库 百科 知识分享

cprogram题急300fenstudent1:allowance?350//enterincome?2500//enterstudent2:allowance?550//enterincome?4500//enterstudent3:allowance?400//enterincome?3500//enterstudent4:allowance?300//enterincome?2500//entersurveyresultsXX.X%s

题目详情
c program 题 急 300fen
student 1:allowance?350// enterincome?2500// enter student 2:allowance?550// enterincome?4500// enter student 3:allowance?400// enterincome?3500// enter student 4:allowance?300// enterincome?2500// enter survey resultsXX.X % student have allowane 500average student monthly allownace is xxx.xthe average income sudents with allowance.>500 is xxxx.xxxx is computer calculation out ..use while loop or for loop
▼优质解答
答案和解析
#include
struct stu
{
int all;
int inc;
}p[4];
int main()
{
int i = 0;
double rate[4] = {0};
for (i = 0; i < 4; i++)
{
scanf("%d",&p[i].all);
fflush(stdin);
scanf("%d",&p[i].inc);
}
for(i = 0; i < 4; i++)
{
if(p[i].all < 300)
rate[0]++;
if(p[i].all >= 300 & p[i].all < 400)
rate[1]++;
if(p[i].all >= 400 & p[i].all < 500)
rate[2]++;
if(p[i].all > 500)
rate[3]++;
}
printf("%.1f %% student have allowane < 300.\n",rate[0] / 4 * 100);
printf("%.1f %% student have allowane 300-400.\n",rate[1] / 4 * 100);
printf("%.1f %% student have allowane 400-500.\n",rate[2] / 4 * 100);
printf("%.1f %% student have allowane > 500.\n",rate[3] / 4 * 100);
return 0;
}
看了 cprogram题急300f...的网友还看了以下: