❶ 請問c語言,最後是顯示出學號和對應的各科成績怎麼編程
基本思路是使用結構體。
如:
structstudent//包含學號,數學成績,英語成績,計算機成績
{
intnum;
intmath;
intenglish;
intcomputer;
};
這樣使用:
structstudenta;
a.num=1;
a.math=59;
a.english=69;
a.computer=79;
printf("%d,%d,%d,%d ",a.num,a.math,a.english,a.computer);
不懂就追問,滿意請採納!
❷ c語言成績等級編寫
#include<stdio.h>
intmain()
{
intscore;
printf("inputascore:");
scanf("%d",&score);
if(score>100||score<0)
printf("輸入數據錯誤 ");
else
{
switch(score/10)
{
case9:case10:
printf("A ");break;
case8:
printf("B ");break;
case7:
printf("C ");break;
case6:
printf("D ");break;
default:
printf("E ");break;
}
}
return0;
}
❸ C語言 從鍵盤輸入一個班的成績 怎麼用while語句實現的程序代碼
#include<stdio.h>
int main()
{
float score;
char grade;
printf("請輸入學生成績:");
scanf_s("%f", &score);
while (score>100||score<0)
{ printf("\n輸入有旦斗蘆誤,銷凳請重新輸入!");
scanf_s("%f"模帶, &score); }
switch ((int)(score / 10))
{
case 10:
case 9:grade = 'A'; break;
case 8:grade = 'B'; break;
case 7:grade = 'C'; break;
case 6:grade = 'D'; break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:grade = 'E';
}
printf("學生成績是%5.1f:,等級是:%C。\n", score, grade);
}
❹ 輸入百分製成績對應輸出優良中及格不及格的成績等級c語言用swich表達
代碼如下虧高襪:
#include <stdio.h>
int main()
{
int grade;
printf("請輸入成銷激績: ");
scanf("%d", &grade);
switch (grade / 10)
{
case 10:
case 9:
printf("優. ");
break;
case 8:
printf("良. ");
break;
case 7:
printf("中念陵. ");
break;
case 6:
printf("及格. ");
break;
default:
printf("不及格. ");
}
return 0;
}