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

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

c語言功能函數(shù)實(shí)現(xiàn)代碼,C語言功能函數(shù)

C語言 如何編寫該程序的主函數(shù),使實(shí)現(xiàn)功能?

#include "stdio.h"#include "conio.h"#include "stdlib.h"#include "string.h"#define MAXSTUDENT (1024)#define CheckData()\{\if(!studentNum)\{\printf("沒有學(xué)生數(shù)據(jù),按任意鍵返回……\n");\getch();\return;\}\}\int studentNum = 0;typedef struct Student{int id;int cScore;int mathScore;}Student;void ClearStudent(Student* student){memset((void*)student,0,sizeof(*student));}void ShowMainMenu(){system("cls");printf("1.增加記錄\n2.計(jì)算每個(gè)學(xué)生的總成績\n3.計(jì)算每門課程的平均成績\n4.按座號查詢學(xué)生的成績\n5.按總分排名\n6.輸出前n名的學(xué)生的成績\n7.修改成績\n0.退出\n");}void ShowCountScore(const Student* student){system("cls");CheckData();for(int i = 0;i studentNum;i++)printf("學(xué)生%04d的總成績:%d\n",(student+i)-id,(student+i)-cScore+(student+i)-mathScore);printf("\n按任意鍵繼續(xù)……");getch();}void ShowClassAvg(const Student* student){system("cls");CheckData();double sumc = 0;double summath = 0;for(int i = 0;i studentNum;i++){sumc += (student+i)-cScore;summath += (student+i)-mathScore;}printf("C語言平均成績?yōu)椋?lf\n",sumc/studentNum);printf("數(shù)學(xué)平均成績?yōu)椋?lf\n",summath/studentNum);printf("\n按任意鍵繼續(xù)……");getch();}void AddStudent(Student* student){system("cls");if(studentNum == MAXSTUDENT){printf("人數(shù)已滿,按任意鍵返回……\n");getch();}printf("分別錄入座號、C語言成績、數(shù)學(xué)成績:\n");int id = 0;int cScore = 0;int mathScore = 0;scanf("%d%d%d",id,cScore,mathScore);for(int i = 0 ;i studentNum;i++)if((student+i)-id == id){printf("座號重復(fù),按任意鍵返回……\n");getch();return;}(student+studentNum)-id = id;(student+studentNum)-cScore = cScore;(student+studentNum)-mathScore = mathScore;studentNum++;}void SelectFromID(const Student* student){system("cls");CheckData();printf("輸入查詢ID:\n");int id = 0;scanf("%d",id);printf("查詢結(jié)果:\n");for(int i = 0;istudentNum;i++)if(id == (student+i)-id){printf("C語言成績?yōu)椋?d\n數(shù)學(xué)成績?yōu)椋?d\n",(student+i)-cScore,(student+i)-mathScore);break;}printf("\n按任意鍵繼續(xù)……");getch();}void SortForCount(Student* student){system("cls");CheckData();for(int i = 0;i studentNum;i++){for(int j = studentNum -1;j i;j--)if(((student+j)-cScore+(student+j)-mathScore) ((student+j-1)-cScore+(student+j-1)-mathScore)){Student stu;stu = *(student+j);*(student+j) = *(student+j-1);*(student+j-1) = stu;}}}void SortForN(Student* student,int n){SortForCount(student);if(!studentNum)return;n = nstudentNum?studentNum:n;for(int i = 0;i n;i++)printf("第%d名:\nID:%d\nC語言成績?yōu)椋?d\n數(shù)學(xué)成績?yōu)椋?d\n總分為:%d\n\n",i+1,(student+i)-id,(student+i)-cScore,(student+i)-mathScore,(student+i)-cScore+(student+i)-mathScore);printf("\n按任意鍵繼續(xù)……");getch();}void UpdateScore(Student* student){system("cls");CheckData();printf("輸入修改ID:\n");int id = 0;scanf("%d",id);int i = 0;for(;istudentNum;i++)if(id == (student+i)-id)break;if(i == studentNum)printf("\n查無此人,按任意鍵繼續(xù)……");else{printf("輸入欲修改的C語言成績、數(shù)學(xué)成績:\n");int cScore = 0;int mathScore = 0;scanf("%d%d",cScore,mathScore);(student+i)-cScore=cScore;(student+i)-mathScore = mathScore;printf("\n按任意鍵繼續(xù)……");}getch();}void RunStudent(Student* student){while(1){ShowMainMenu();char chGet = getch();switch(chGet){case '1':AddStudent(student);break;case '2':ShowCountScore(student);break;case '3':ShowClassAvg(student);break;case '4':SelectFromID(student);break;case '5':SortForCount(student);for(int i =0;istudentNum;i++)printf("第%d名:\nID:%d\nC語言成績?yōu)椋?d\n數(shù)學(xué)成績?yōu)椋?d\n總分為:%d\n\n",i+1,(student+i)-id,(student+i)-cScore,(student+i)-mathScore,(student+i)-cScore+(student+i)-mathScore);printf("\n按任意鍵繼續(xù)……");getch();break;case '6':{int n = 0;printf("輸入N:\n");scanf("%d",n);SortForN(student,n);}break;case '7':UpdateScore(student);break;case '0':return;default:break;}}}int main(){Student* allStudent = (Student*)malloc(MAXSTUDENT*sizeof(Student));memset((void*)allStudent,0,MAXSTUDENT*sizeof(Student));RunStudent(allStudent);return 0;}

站在用戶的角度思考問題,與客戶深入溝通,找到渠縣網(wǎng)站設(shè)計(jì)與渠縣網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋渠縣地區(qū)。

c程序語言,函數(shù),求編程實(shí)現(xiàn)

第三個(gè)函數(shù)

#includestdio.h

void

main()

{

int

a,b,back;

int

mulnum(int

a,int

b);

printf("請輸入兩個(gè)整數(shù):");

scanf("%d%d",a,b);

back=mulnum(a,b);

if(back==1)

printf("%d

is

multiple

of

%d\n",a,b);

else

if(back==2)

printf("%d

is

multiple

of

%d\n",b,a);

else

;

}

int

mulnum(int

a,int

b)

{

double

result;

if((result=a%b)==0)

return

1;

else

if((result=b%a)==0)

return

2;

else

return

0;

}

這個(gè)函數(shù)能技能判斷a是否為b的倍數(shù),還能判斷b是否為a的倍數(shù)。樓主如果不需要第二個(gè)功能,把else

if語句

去掉就行了。

c語言:編寫函數(shù)實(shí)現(xiàn)功能,并用相應(yīng)的主函數(shù)進(jìn)行測試?

#includestdio.h

void delStr(char *s,char p)

{char *p1,*p2;

for(p1=p2=s;*p1;p1++)

if(*p1!=p)*p2++=*p1;

*p2='\0';

}

int main()

{char s[300],ch;

gets(s);

ch=getchar();

delStr(s,ch);

printf("%s\n",s);

return 0;

}


本文名稱:c語言功能函數(shù)實(shí)現(xiàn)代碼,C語言功能函數(shù)
文章源于:http://weahome.cn/article/hesohe.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部