當前位置:首頁 » 編程語言 » c語言編寫非法成績
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言編寫非法成績

發布時間: 2023-03-24 00:36:49

c語言:輸入學生成績,輸入非法成績時退出,求平均分。 求問如下:倒數第二行scanf("%f",&sc); 的意義

scanf("%f",&sc);//輸入第一個成績
while(sc>0&&sc<=150)
{s+=sc;
i++;
scanf("%f",&sc);//輸喚山團入下一個成績,這個執行後會跳到while,於唯余是判斷是否非法,如果非法則退出while,否和橘則繼續循環。
}

㈡ 用c語言編寫程序: 學生的成績管理功能

暈 你給的分太少了 這個可以作為畢業設計的題目了

㈢ 在C語言編程中,給出一個百分製成績,要求輸出成績等級

#include <stdio.h>

int main()

{

int score, m;

scanf("%d", &score);

while (score < 0 || score > 100){

printf("Error! Retry! ");

scanf("%d", &score);

}

m= score / 10;

if (m>= 9)

printf("Grade is A! ");

switch(m){

case 0: printf("Grade is E! "); break;

case 1: printf("Grade is E! "); break;

case 2:printf("Grade is E! "); break;

case 3:printf("Grade is E! "); break;

case 4:printf("Grade is E! "); break;

case 5: printf("Grade is E! "); break;

case 6: printf("Grade is D! "); break;

case 7: printf("Grade is C! "); break;

case 8: printf("Grade is B! "); break;

}

return 0;

}

(3)c語言編寫非法成績擴展閱讀

其他實現輸出成績等級『A'、』B『、'C'、『D'、'E』。90分以上為A,80~89分為B,70~79分為C,60~69分為D,60分一下為E的方法:

#include <stdio.h>

int main()

{

int score;

scanf("%d", &score);

while (score < 0 || score >100){

printf("Error! Retry! ");

scanf("%d", &score);

}

if (score < 60)

printf("Grade is E! ");

else if (score >= 60 && score < 70)

printf("Grade is D! ");

else if (score >= 70 && score < 80)

printf("Grade is C! ");

else if (score >=80 && score < 90)

printf("Grade is B! ");

else

printf("Grade is A! ");

return 0;

}

㈣ c語言編寫學生成績處理

//給你個示例,僅供參考
#include<stdio.h>
#include<stdlib.h>

#defineNO_LEN11
#defineNAME_LEN9
#defineSTUDENT_NUM5
#defineTOP_THREE3

typedefstructstudent
{
charno[NO_LEN];
charname[NAME_LEN];
floata;
floatb;
floatc;
floatavg;
}ST;//st[STUDENT_NUM];

intget_student_info(ST*st,intlen);
voiddisplay(constST*st,intlen);
voidcalculate_average(ST*st,intlen);
voidsort(ST*st,intlen);


intmain(intargc,char*argv[])
{
STst[STUDENT_NUM];

get_student_info(st,STUDENT_NUM);
calculate_average(st,STUDENT_NUM);
sort(st,STUDENT_NUM);

display(st,STUDENT_NUM);
display(st,TOP_THREE);


return0;
}

/*從鍵盤輸入STUDENT_NUM個學生的信息*/
intget_student_info(ST*st,intlen)
{
inti=0,ret=0;
if(0==st||0>=len||STUDENT_NUM<len)
{
printf("parametererror ");
returnret=1;
}

for(;i<len;++i)
{
printf("輸入第%d個學號、姓名、三門課成績:",i+1);
scanf("%10s%8s%f%f%f",st[i].no,st[i].name,&st[i].a,&st[i].b,&st[i].c);
}

returnret;
}

/*顯示前len個學生的信息*/
voiddisplay(constST*st,intlen)
{
inti=0;
if(0==st||0>=len||STUDENT_NUM<len)
{
printf("parametererror ");
return;
}

printf("================================== ");
for(;i<len;++i)
{
printf("%s%s%.1f%.1f%.1f%.1f ",
st[i].no,st[i].name,st[i].a,st[i].b,st[i].c,st[i].avg);
}
}

/*計算每個學生的平均成績*/
voidcalculate_average(ST*st,intlen)
{
inti=0;
if(0==st||0>=len||STUDENT_NUM<len)
{
printf("parametererror ");
return;
}

for(;i!=len;++i)
{
st[i].avg=(st[i].a+st[i].b+st[i].c)/3.0;
}
}

/*冒泡排序降序排列*/
voidsort(ST*st,intlen)
{
inti=0,j=0;
STtmp;
if(0==st||0>=len||STUDENT_NUM<len)
{
printf("parametererror ");
return;
}
for(;i<len-1;++i)
{
for(j=0;j<len-1-i;++j)
{
if(st[j].avg<st[j+1].avg)
{
tmp=st[j];
st[j]=st[j+1];
st[j+1]=tmp;
}
}
}
}

㈤ 用C語言編一個成績記錄簿

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#defineMAX1000

typedefstructLesson//定義課程結構體
{
intLesson_Num;
charLesson_Name[50];
intLesson_Mark;
intLesson_Credit;
}Lesson;

typedefstructStudent//定義學生的結構體
{
charName[50];
intNum;
intLesson_Count;
LessonL[20];
}Student;

StudentS[MAX];
staticintStudent_Count=0;//記錄學生數的變數

voidPrintInterface();//列印界面
intAddStudent();//添加,帶返回值,提示操作成功
intDelStudent();//刪除,帶返回值,提示操作成功
voidCheckStudent();//查學生成績
voidCheckClass();//查班成績表
voidWriteFile();//寫入文本文件
voidReadFile();//讀取文本文件

voidmain()
{
intChoice;
while(1)
{
PrintInterface();
scanf("%d%*c",&Choice);//"%*c"是吸收回車的,因為後面會輸入字母類型
if(Choice>=0&&Choice<=6)//選擇操作合法
{
switch(Choice)
{
case0:exit(1);
case1:
{
system("cls");
if(AddStudent())printf(" 添加成功...回車繼續 ");
elseprintf(" 添加失敗...回車繼續 ");
getchar();
getchar();
system("cls");
break;
}
case2:
{
system("cls");
if(DelStudent())printf(" 刪除成功...回車繼續 ");
elseprintf(" 刪除失敗...回車繼續 ");
getchar();
getchar();
system("cls");
break;
}
case3:
{
system("cls");
CheckStudent();
system("cls");
break;
}
case4:
{
system("cls");
CheckClass();
system("cls");
break;
}
case5:WriteFile();system("cls");break;
case6:ReadFile();system("cls");break;
default:;
}
}
else
{
printf("無此功能..重新選擇..回車確定 ");//選擇操作非法
getchar();
system("cls");//清屏函數
}
}
}

voidPrintInterface()
{
printf(" -------------------------- ");
printf(" |1、添加| ");
printf(" || ");
printf(" |2、刪除| ");
printf(" || ");
printf(" |3、查學生成績| ");
printf(" || ");
printf(" |4、查班成績表| ");
printf(" || ");
printf(" |5、寫入文本文件| ");
printf(" || ");
printf(" |6、讀取文本文件| ");
printf(" || ");
printf(" |0、退出| ");
printf(" -------------------------- ");
printf(" 選擇操作:");
}

intAddStudent()
{
intS_count,i,j;
printf(" 添加中...... ");
printf(" 添加學生人數(如1、2……999):");
scanf("%d",&S_count);
if(Student_Count+S_count>=MAX)return0;//超過了數組上限
for(i=Student_Count;i<Student_Count+S_count;i++)
{
printf(" 第%d個學生: ",i-Student_Count+1);
printf(" 學生學號:");scanf("%d%*c",&S[i].Num);
printf(" 學生姓名:");gets(S[i].Name);
printf(" 該學生所修課程數:");scanf("%d",&S[i].Lesson_Count);
for(j=0;j<S[i].Lesson_Count;j++)
{
printf(" 第%d門課: ",j+1);
printf(" 課程編號:");scanf("%d%*c",&S[i].L[j].Lesson_Num);
printf(" 課程名稱:");gets(S[i].L[j].Lesson_Name);
printf(" 課程成績:");scanf("%d",&S[i].L[j].Lesson_Mark);
printf(" 課程學分:");scanf("%d",&S[i].L[j].Lesson_Credit);
if(S[i].L[j].Lesson_Mark<60)S[i].L[j].Lesson_Credit=0;//不及格的課程學分為0
}
}
Student_Count+=S_count;
return1;
}

intDelStudent()
{
char*D_Name;
intD_Num;
inti,j;
printf(" 填寫待刪除學生的信息: ");
printf(" 學生姓名:");gets(D_Name);
printf(" 學生學號:");scanf("%d",&D_Num);
for(i=0;i<Student_Count;i++)
{
if(!strcmp(S[i].Name,D_Name)&&S[i].Num==D_Num)
{
printf(" 找到該學生,刪除中...... ");
for(j=i+1;j<Student_Count;j++)
{
S[j-1]=S[j];
}
break;
}
}
if(i==Student_Count)
{
printf(" 未找到該學生...請核對所填信息 ");
return0;
}
else
{
Student_Count--;
return1;
}
}

voidCheckStudent()
{
intC_Choice;
charC_Name[50];
intC_Num;
inti,j;
printf(" 輸入所查學生信息(1.姓名\2.學號)選擇:");
scanf("%d%*c",&C_Choice);
printf(" 查找中...... ");
if(C_Choice==1||C_Choice==2)//選擇合法
{
if(C_Choice==1)
{
printf(" 姓名:");gets(C_Name);
for(i=0;i<Student_Count;i++)//全部窮舉,防止同名同姓
{
if(!strcmp(S[i].Name,C_Name))
{
printf(" 學號:%d 姓名:%s ",S[i].Num,S[i].Name);
printf(" 課程編號 課程名稱 課程成績 課程學分 ");
printf("----------------------------------------------------- ");
for(j=0;j<S[i].Lesson_Count;j++)
{
printf("%d %s %d %d ",S[i].L[j].Lesson_Num,
S[i].L[j].Lesson_Name,S[i].L[j].Lesson_Mark,
S[i].L[j].Lesson_Credit);
printf("----------------------------------------------------- ");
}
printf(" ");
}
}
}
else
{
printf(" 學號:");scanf("%d%*c",&C_Num);
for(i=0;i<Student_Count;i++)//不用全部窮舉,學號唯一
{
if(S[i].Num==C_Num)
{
printf(" 學號:%d 姓名:%s ",S[i].Num,S[i].Name);
printf(" 課程編號 課程名稱 課程成績 課程學分 ");
printf("----------------------------------------------------- ");
for(j=0;j<S[i].Lesson_Count;j++)
{
printf("%d %s %d %d ",S[i].L[j].Lesson_Num,
S[i].L[j].Lesson_Name,S[i].L[j].Lesson_Mark,
S[i].L[j].Lesson_Credit);
printf("----------------------------------------------------- ");
}
printf(" ");
break;
}
}
}
printf("查找完畢...回車繼續 ");
getchar();
}
else//選擇不合法
{
printf("選擇錯誤...回車繼續 ");
getchar();
return;
}
}

voidCheckClass()
{
intC_LNum;
doubleSSNum=0,PassSNum=0,SMark=0;
inti,j;
printf(" 請輸入課程編號:");
scanf("%d%*c",&C_LNum);
printf(" 查找中...... ");
printf("學號 姓名 課程名稱 課程成績 課程學分 ");
printf("---------------------------------------------------- ");
for(i=0;i<Student_Count;i++)
{
for(j=0;j<S[i].Lesson_Count;j++)
{
if(S[i].L[j].Lesson_Num==C_LNum)
{
printf("%d %s %s %d %d ",S[i].Num,S[i].Name,S[i].L[j].Lesson_Name,
S[i].L[j].Lesson_Mark,S[i].L[j].Lesson_Credit);
printf("---------------------------------------------------- ");
SMark+=S[i].L[j].Lesson_Mark;
SSNum++;
if(S[i].L[j].Lesson_Mark>=60)PassSNum++;
break;
}
}
}
printf(" 平均分:%.2lf 及格率:%.2lf%% ",SMark/SSNum,PassSNum/SSNum*100);
printf(" 查找完畢...回車繼續 ");
getchar();
}

voidWriteFile()
{
FILE*fp;
inti,j;
charAdr[100];
printf(" 請輸入寫入的文件地址: 地址輸入格式:例如d:\\Student.txt(\\為轉義字元):");
scanf("%s%*c",Adr);
printf(" 寫入中...... ");
if(fp=fopen(Adr,"w"))//寫入文件
{
fprintf(fp,"%d ",Student_Count);
for(i=0;i<Student_Count;i++)
{
fprintf(fp,"%d %s %d ",S[i].Num,S[i].Name,S[i].Lesson_Count);
for(j=0;j<S[i].Lesson_Count;j++)
{
fprintf(fp,"%d %s %d %d ",S[i].L[j].Lesson_Num,
S[i].L[j].Lesson_Name,S[i].L[j].Lesson_Mark,
S[i].L[j].Lesson_Credit);
}
}
printf(" 寫入完成...回車繼續 ");
fclose(fp);
}
else
{
printf(" 寫入失敗...回車繼續 ");
}
getchar();
}
voidReadFile()
{
FILE*fp;
inti,j;
charAdr[100];
printf(" 請輸入讀取(為防止讀入錯誤,希望與寫入文件內容格式一致)的文件地址: 地址輸入格式:例如d:\\Student.txt(\\為轉義字元):");
scanf("%s%*c",Adr);
printf(" 讀取中...... ");
if(fp=fopen(Adr,"r"))
{
fscanf(fp,"%d",&Student_Count);
for(i=0;i<Student_Count;i++)
{
fscanf(fp,"%d%s%d",&S[i].Num,&S[i].Name,&S[i].Lesson_Count);
for(j=0;j<S[i].Lesson_Count;j++)
{
fscanf(fp,"%d%s%d%d",&S[i].L[j].Lesson_Num,
&S[i].L[j].Lesson_Name,&S[i].L[j].Lesson_Mark,
&S[i].L[j].Lesson_Credit);
}
}
printf(" 讀取成功...回車繼續 ");
fclose(fp);
}
else
{
printf(" 讀取失敗...回車繼續 ");
}
getchar();
}

㈥ C語言統計分數,分別計算及格人數和不及格人數,輸入非法分數時退出

#include<stdio.h>
void main()
{
int score=0,i=0,j=0;//score記錄分數,i記錄及格人數,j記錄不及格人數
printf("輸入成績(0-100),輸入-1時退出:\n");
while(1)
{
scanf("%d",&score);
if(score==-1)//輸入-1,退出系統
{
printf("輸入結束,退出系統\n");
return;
}
else if(score>100||score<0)//輸入非法分數,巧攔退出
{
printf("錄入數據錯誤,退出系統\n");
return;
}
if(score>=60){i++;printf("及格人數為:%d,不及格人數為%d\n",i,j);}//輸入數據正常,分數在60-100,及格人數加一,並輸出
else if(score<60){j++;printf("及格人數為:%d,不及格人數為%d\n",i,j);}//輸入數據正常,分數在0-59,不及格人數加一,並輸出
}
}

運行結果:
======================================
輸入成績(0-100),輸入-1時退出:
85
及格人數為:1,不及格人數為0
75
及格人數為:2,不及伍鋒格人數為0
49
及格人數為:2,不及格人數為孝橘胡1
89
及格人數為:3,不及格人數為1
56
及格人數為:3,不及格人數為2
72
及格人數為:4,不及格人數為2
-1
輸入結束,退出系統
Press any key to continue
======================================

㈦ C語言編寫學生成績管理系統的不及格成績的查詢

使用鏈表,定義結構體,結構體變數如下:姓名、學號、成績1,2,3,總分,平均分。
功能1、查詢鏈表即可,以姓名、學號遍歷鏈表,列印成績。1.1遍歷鏈禪兆表,添加條件查找不及格的學生並列印。
功能2、即鏈表中模虧的添加元素即可。
功能3、創建另一個TEMP鏈表,對當前鏈表中的數據進行排序,從小到大依次將數據添加到新的鏈表中,列印即可。
功能4、同理,旦襲神添加限制條件列印即可

㈧ 用c語言編寫輸入一學生成績,和相應優秀,良好,不及格信息

#include<stdio.h>
#include<stdlib.h>
#include"windows.h"

intmain(intargc,char*argv[])
{
intcj;
do{
system("cls");
printf("請輸入成績:");
scanf("%d",&cj);
if(cj>0&&cj<101)
{
if(cj>=90&&cj<=100)
printf(" 優秀 ");
elseif(cj>=70&&cj<=89)
printf(" 良好 ");
elseif(cj>=60&&cj<=69)
printf(" 及格 ");
elseif(cj>=0&&cj<=59)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
printf(" 不及格 ");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN);
}
}
else
{
printf(" error ");
}
printf(" 如果要繼續請按y ");
fflush(stdin);
cj=_getch();
}
while(cj=='y');
return0;
}

㈨ C語言 輸出不及格學生的成績

#include<stdio.h>
int main()
{
int i,b=0,j=0,l=0,y=0,a[10];
printf("請輸入10個學生仔明頌的成績\n");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
for(i=0;i<10;i++)
{
if(a[i]<60)
{
b++;
}
else if(a[i]<70)
{
j++;
}
else if(a[i]<80)
{
l++;
}
else if(a[i]<=100)
{
y++;
}
}
printf("優秀%d\念鄭n",y);
printf("良好%d\n",l);
printf("槐友及格%d\n",j);
printf("不及格%d\n",b);
return 0;
}

㈩ 如何用C語言編程出「給出一個百分製成績,要求輸出成績等級」

因為你的score是char類型,char單字元的話,只能讀一個字元。比如你輸入80,其實讀入的是8,所以讀入的數字一定小於10,自然就是E了

不信的話可以看下如下代碼的結果

代碼之路還很長,樓主加油~~

至於怎麼改,改成int輸入即可。