真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網站制作重慶分公司

c語言函數(shù)調用成績單 c語言實現(xiàn)成績查詢

C語言制作成績單

#include stdio.hstruct stud

創(chuàng)新互聯(lián)堅信:善待客戶,將會成為終身客戶。我們能堅持多年,是因為我們一直可值得信賴。我們從不忽悠初訪客戶,我們用心做好本職工作,不忘初心,方得始終。10多年網站建設經驗創(chuàng)新互聯(lián)是成都老牌網站營銷服務商,為您提供成都網站制作、做網站、外貿營銷網站建設、網站設計、H5高端網站建設、網站制作、品牌網站設計、重慶小程序開發(fā)服務,給眾多知名企業(yè)提供過好品質的建站服務。

{

int num;

char name[20];

float score1, score2, score3, aver;

}; int main(void)

{

int high;

int i, j;

struct stud myClass[10], *pStu = myClass;

struct stud temp; printf("Please input students info:Num Name score1 score2 score3\n");

for (i = 0; i 10; i++)

{

printf("%d:", i + 1);

scanf("%d %s %f %f %f", myClass[i].num, myClass[i].name, myClass[i].score1,

myClass[i].score2, myClass[i].score3);

myClass[i].aver = (myClass[i].score1 + myClass[i].score2 + myClass[i].score3) / 3;

} high = 0;

for (i = 0; i 10; i++)

{

if (myClass[i].aver myClass[high].aver)

{

high = i;

}

} printf("\nThe Highest is %s(%d)\nscore1=%.2f score2=%.2f score3=%.2f aver=%.2f\n",

myClass[high].name, myClass[high].num,

myClass[high].score1, myClass[high].score2, myClass[high].score3, myClass[high].aver); for (i = 0; i 9; i++)

{

for (j = i + 1; j 10; j++)

{

if ((pStu + j)-aver (pStu + i)-aver)

{

temp = *(pStu + j);

*(pStu + j) = *(pStu + i);

*(pStu + i) = temp;

}

}

} printf("\nResult of sort:\n");

printf("Num Name score1 score2 score3 average\n");

for (i=0; i10; i++)

{

printf("%-5d %-20s %-8.2f %-8.2f %-8.2f %-.2f\n", (pStu+i)-num, (pStu+i)-name,

(pStu+i)-score1, (pStu+i)-score2, (pStu+i)-score3, (pStu+i)-aver);

}

return 0;

}

C語言怎么輸出一個成績表

#include?stdio.h

int?main()

{

float?score[2][2]?=?{0};

for?(int?i?=?0;?i??2;?i++)

{

for?(int?j?=?0;?j??2;?j++)

{

scanf("%f",?score[i][j]);

}

}

printf("----------------------\n");

printf("序號語文??數(shù)學??總成績\n");

printf("----------------------\n");

for?(int?i?=?0;?i??2;?i++)

{

printf("%-4d%-6.1f%-6.1f%6.1f\n",?i?+?1,?score[i][0],?score[i][1],?score[i][0]?+?score[i][1]);

}

return?0;

}

//測試輸出:

//80.0

//90.5

//90.5

//70.5

//----------------------

//序號語文??數(shù)學??總成績

//----------------------

//1???80.0??90.5???170.5

//2???90.5??70.5???161.0

怎么用C語言編一個學生成績記錄簿?

#includestdio.h

#includestdlib.h

#includestring.h

typedef struct

{

char id[15];

char name[10];

int score;

} StudentInfo;

typedef struct

{

StudentInfo arr[100];

int length;

} SeqList;

FILE *fp;

char *filePath = "C:/StudentInfo.txt";

void initSeqList(SeqList *L)

{

L-length = 0;

}

void insertSeqList(SeqList *L, int i, StudentInfo info)?

{

int j;

for(j = L-length; j i; j--)

L-arr[j] = L-arr[j-1];

L-arr[j] = info;

L-length++;

}

void printStudentInfo(StudentInfo info)

{

printf("%s\t%s\t%d\n", info.id, info.name, info.score);

}

void printSeqListWithSeqNo(SeqList L)

{

for(int i = 0; i L.length; i++)

{

printf("%d\t", i+1);

printStudentInfo(L.arr[i]);

}

}

void printSeqList(SeqList L)

{

for(int i = 0; i L.length; i++)

printStudentInfo(L.arr[i]);

}

int queryInfoById(SeqList L, char *id)

{

for(int i = 0; i L.length; i++)

if(strcmp(id, L.arr[i].id)==0)

return i;

return -1;

}

int queryInfoByName(SeqList L, char *name)

{

for(int i = 0; i L.length; i++)

if(strcmp(name, L.arr[i].name)==0)

return i;

return -1;

}

void save2File(SeqList L)

{

fp = fopen(filePath, "w");

for (int i = 0; i L.length; i++)

fprintf(fp, "%s\t%s\t%d\n", L.arr[i].id, L.arr[i].name, L.arr[i].score);

}

void showMenu(SeqList L);

void addInfo(SeqList L)

{

StudentInfo info;

int index;

do {

printf("請輸入學號:");

scanf("%s", info.id);

index = queryInfoById(L, info.id);

if (index != -1)

{

printf("輸入的學號已存在。\n");

printStudentInfo(L.arr[index]);

}

} while(index != -1);

do {

printf("請輸入姓名:");

scanf("%s", info.name);

index = queryInfoByName(L, info.name);

if(index != -1)

{

printf("輸入的姓名已存在。\n");

printStudentInfo(L.arr[index]);

}

} while(index != -1);

printf("請輸入成績:");

scanf("%d", info.score);

L.arr[L.length] = info;

L.length++;

save2File(L);

}

void editInfo(SeqList L)

{

StudentInfo info;

char choice;

printf("1. 按學號修改\n2. 按姓名修改\n3. 返回上一層\n");

while((choice=getchar())=='\n');

int index;

if(choice == '1' || choice == '2')

{

if(choice == '1')

{

printf("請輸入學號:");

scanf("%s", info.id);

index = queryInfoById(L, info.id);

} else {

printf("請輸入姓名:");

scanf("%s", info.name);

index = queryInfoByName(L, info.name);

}

if(index != -1)

printStudentInfo(L.arr[index]);

else {

printf("%s 為 %s 的學生不存在\n", choice==1?"學號":"姓名", choice==1?info.id:info.name);

editInfo(L);

return;

}

printf("成績改為:");

scanf("%d", L.arr[index].score);

save2File(L);

}else if(choice == '3')

showMenu(L);

else {

printf("選擇有誤,請重新選擇\n");

editInfo(L);

return;

}

}

void insertSort(SeqList *L)

{

for(int j = 1; j L-length; j++)

{

StudentInfo key = L-arr[j];

int i = j - 1;

while(i = 0 L-arr[i].score key.score)

{

L-arr[i+1] = L-arr[i];

i--;

}

L-arr[i+1] = key;

}

}

void statisticInfo(SeqList L)

{

// 顯示 60 分以下、60~79、80~89、90 分以上各分數(shù)段的學生信息

SeqList sectionListArr[4];

for (int i = 0; i 4; i++)

initSeqList(sectionListArr[i]);

float sum = 0, average, passedRate;

for (int i = 0; i L.length; i++)

{

int score = L.arr[i].score;

sum += score;

if(score 60)

insertSeqList(sectionListArr[0], sectionListArr[0].length, L.arr[i]);

else if(score = 60 score 80)

insertSeqList(sectionListArr[1], sectionListArr[1].length, L.arr[i]);

else if(score = 80 score 90)

insertSeqList(sectionListArr[2], sectionListArr[2].length, L.arr[i]);

else insertSeqList(sectionListArr[3], sectionListArr[3].length, L.arr[i]);

}

average = sum/L.length;

passedRate = (L.length-sectionListArr[0].length)*100.0/L.length;

insertSort(L);

printf("60 分以下的學生:\n");

printSeqList(sectionListArr[0]);

printf("\n60 ~ 79 分的學生:\n");

printSeqList(sectionListArr[1]);

printf("\n80 ~ 89 分的學生:\n");

printSeqList(sectionListArr[2]);

printf("\n90 分以上的學生:\n");

printSeqList(sectionListArr[3]);

printf("\n及格率:%.1f %%\n平均分:%.1f\n", passedRate, average);

printf("按順序從高到低排序:\n");

insertSort(L);

printSeqListWithSeqNo(L);

printf("\n最高分:\n");

printStudentInfo(L.arr[0]);

printf("\n最低分:\n");

printStudentInfo(L.arr[L.length-1]);

}

void queryInfo(SeqList L)

{

char choice;

printf("1. 按學號查詢\n2. 按姓名查詢\n3. 返回上層\n");

while((choice=getchar())=='\n');

int index;

if (choice == '1')

{

char id[15];

printf("請輸入學號:");

scanf("%s", id);

index = queryInfoById(L, id);

} else if(choice == '2') {

char name[10];

printf("請輸入姓名:");

scanf("%s", name);

index = queryInfoByName(L,name);

} else if(choice == '3') {

showMenu(L);

return;

} else {

printf("選擇有誤,請重新選擇\n");

queryInfo(L);

return;

}

if(index == -1)

printf("沒有查詢到結果\n");

else

printStudentInfo(L.arr[index]);

}

void showMenu(SeqList L)

{

char choice;

printf("\n1. 查詢\n2. 添加成績\n3. 修改成績\n4. 統(tǒng)計分析\n5. 退出\n");

while((choice = getchar()) == '\n');

switch(choice)

{

case '1': queryInfo(L); break;

case '2': addInfo(L); break;

case '3': editInfo(L); break;

case '4': statisticInfo(L); break;

case '5': exit(0);

}

}

int main(void)

{

StudentInfo temp;

SeqList *L = (SeqList*)malloc(sizeof(SeqList));

do {

initSeqList(L);

fp = fopen(filePath, "r");

int i = 0;

while(fscanf(fp, "%s%s%d", temp.id, temp.name, temp.score) != EOF)

insertSeqList(L, i++, temp);

showMenu(*L);

fclose(fp);

}while(1);

return 0;

}

在c語言中用調用函數(shù)求三個同學三科的總成績,怎么編程

#include?stdio.h?

#define?N?100

/*定義學生結構體*/????

struct?Student????

{????

int??ID;???

char?Name[20];???

float?Mark1;????

float?Mark2;??

float?Mark3;?

float?Sum;????

};???

/*聲明學生數(shù)組及學生數(shù)量*/????

struct?Student?students[N];????

//int?num=0;??

/*求總分*/????

float?Sums(struct?Student?stu)???

{????

return?stu.Mark1+stu.Mark2+stu.Mark3;??

}????

/*輸入學生信息*/????

int?Student_Input(){??

int?num=0;

while(1){????

//printf("請輸入學號:");???

students[num].ID=num+1;?//可以自行將學號改為手工輸入

printf("請輸入姓名:");?

scanf("%s",students[num].Name);??

getchar();??

printf("請輸入成績1:");?

scanf("%f",students[num].Mark1);?

getchar();??

printf("請輸入成績2:");?

scanf("%f",students[num].Mark2);?

printf("請輸入成績3:");?

scanf("%f",students[num].Mark3);?

getchar();??

students[num].Sum=Sums(students[num]);???

num++;??

printf("是否繼續(xù)?(y/n)");?//繼續(xù)輸入數(shù)據(jù)?

if?(getchar()=='n'){??

break;??

}????

}??

return?num;??

}??

/*輸出學生信息*/???

void?Student_Display(int?n)???

{???

int?i;????

printf("%10s%10s%8s%8s%8s%8s\n","學號","姓名","成績","成績","成績","總成線");??

printf("---------------------------------------------------------\n");??

for?(i=0;in;i++)??

{??

printf("%10d%10s%8.2f%8.2f%8.2f%8.2f\n",students[i].ID,students[i].Name,??

students[i].Mark1,students[i].Mark2,students[i].Mark3,students[i].Sum);??

}??

}?

/*主程序*/????

int??main(){?

int?n=0;

n=Student_Input();

Student_Display(n);?

return?0;??

}


網站題目:c語言函數(shù)調用成績單 c語言實現(xiàn)成績查詢
網站路徑:http://weahome.cn/article/ddgejcd.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部