關於getfailnum在c語言的信息

本文目錄一覽:

跪求學生成績管理系統設計(C語言程序設計)

這是我在大學時做的,你看看:

/*

程序功能:

能完成每位學生的某門課程的平時成績和期末考試成績的錄入,

完成每位學生的總評成績計算(平時成績*30%+期末考試成績*70%)並生成數據文件,

生成分數段統計文件(不及格人數,60-69數,70-79人數,80-89人數,90-100人數,及格

率),

通過學生成績的數據文件查詢學生成績(查詢條件自定)。

通過學生成績的分段統計文件輸出學生成績分段情況和及格率。

程序要求:

(1)能夠完成300人以內任何人數的成績處理。

(2)程序要有主控菜單

*/

#includestdio.h

#includestdlib.h

#includestring.h

struct stud

{

long num;

char name[20];

double score;

};

typedef struct stucode

{

struct stud student ;

struct stucode *next;

}L;

void menu();

void createlist(struct stucode **r);

void out(struct stucode *r);

void search1(struct stucode *r);

void search2(struct stucode *r);

void del(struct stucode **r);

void insert(struct stucode **r);

void sort(struct stucode **r);

void main()

{

char choose;

int flag=1;

struct stucode *r=NULL;

while(flag)

{

system(“cls”);

menu();

choose=getchar();

switch(choose)

{

case ‘1’:

createlist(r);

out(r);

printf(“Testing function 1\nPress any key to continue\n”);

getchar();

getchar();

break;

case ‘2’:

search1(r);

printf(“Testing function 1\nPress any key to continue\n”);

getchar();

getchar();

break;

case ‘3’:

search2(r);

printf(“Testing function 1\nPress any key to continue\n”);

getchar();

getchar();

break;

case ‘4’:

del(r);

out(r);

printf(“Testing function 1\nPress any key to continue\n”);

getchar();

getchar();

break;

case ‘5’:

insert(r);

out(r);

printf(“Testing function 1\nPress any key to continue\n”);

getchar();

getchar();

break;

case ‘6’:

sort(r);

out(r);

printf(“Testing function 1\nPress any key to continue\n”);

getchar();

getchar();

break;

case ‘7’:

out(r);

printf(“Testing function 7\nPress any key to continue\n”);

getchar();

getchar();

break;

case ‘0’:

flag=0;

printf(“The end.\n”);

break;

default: printf(“\nWrong Selection!(選擇錯誤,請重選!)\n”);getchar();getchar();

}

}

}

void createlist(struct stucode **r)

{

struct stucode *p,*t;

long n;

char a[20];

double s;

if(*r) *r=NULL;

printf(” \n請輸入:\n 學號(請按學號升序排列) 姓名 分數 (若要結束請輸入三個為零)

\n”);

scanf(“%ld%s%lf”,n,a,s);

if(n==0) return;

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

p-student.num=n;

strcpy(p-student.name,a);

p-student.score=s;

p-next=NULL;

*r=p;

scanf(“%ld%s%lf”,n,a,s);

while(n)

{

t=p;

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

p-student.num=n;

strcpy(p-student.name,a);

p-student.score=s;

p-next=NULL;

t-next=p;

scanf(“%ld%s%lf”,n,a,s);

}

}

void search1(struct stucode *r)

{

long x;

if(!r)

{

printf(“沒有學生信息可查詢!\n”);

return ;

}

printf(” 請輸入要查詢的學生信息的學生學號:\n”);

scanf(“%ld”,x);

while(rr-student.num!=x)

r=r-next;

if(r==NULL)

printf(“Error! No such student !\n”);

else

printf(“%ld %s %.2lf\n”,r-student.num,r-student.name,r-student.score);

}

void search2(struct stucode *r)

{

char m[20];

if(!r)

{

printf(“沒有學生信息可查詢!\n”);

return ;

}

printf(” 請輸入要查詢的學生信息的學生姓名:\n”);

scanf(“%s”,m);

while(rstrcmp(r-student.name,m))

r=r-next;

if(r==NULL)

printf(“Error! No such student !\n”);

else

printf(“%ld %s %.2lf\n”,r-student.num,r-student.name,r-student.score);

}

void del(struct stucode **r)

{

long k;

struct stucode *p=*r,*t;

if(!(*r))

{

printf(“沒有學生信息可刪除 !\n”);

return ;

}

printf(” 請輸入要刪除的學生信息的學生學號:\n”);

scanf(“%ld”,k);

if(p-student.num==k)

*r=(*r)-next,free(p);

else

{

while(p-nextp-next-student.num!=k)

p=p-next;

if(p-next==NULL)

printf(“Error! No such student !\n”);

else

{

t=p-next;

p-next=p-next-next;

free(t);

}

}

}

void insert(struct stucode **r)

{

long n;

char a[20];

double s;

L *p,*t,*k;

printf(” 請輸入要插入的學生信息的學生學號 姓名 分數:\n”);

scanf(“%ld%s%lf”,n,a,s);

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

p-student.num=n;

p-student.score=s;

strcpy(p-student.name,a);

if(!(*r))

{

*r=p;

(*r)-next=NULL;

return ;

}

if(p-student.num(*r)-student.num)

p-next=(*r),(*r)=p;

else

{

t=*r;

k=t;

while(t-nextt-next-student.num=p-student.num)

t=t-next;

p-next=t-next;

t-next=p;

*r=k;

}

}

void sort(struct stucode **r)

{

struct stucode *t,*p,*q,*z;

if(!r)

{

printf(“沒有學生信息可排序!\n”);

return ;

}

if(!(*r)||!(*r)-next)

return;

t=*r;

p=t-next;

t-next=NULL;

while(p)

{

q=p-next;

if(p-student.scoret-student.score)

{

p-next=t;

t=p;

}

else

{

z=t;

while(z-nextz-next-student.score=p-student.score)

z=z-next;

p-next=z-next;

z-next=p;

}

p=q;

}

*r=t;

}

void out(struct stucode *r)

{

printf(“\n\n”);

if(!r)

{

printf(“沒有學生信息可輸出!\n”);

return ;

}

while(r)

{

printf(“%ld %s %.2lf\n”,r-student.num,r-student.name,r-student.score);

r=r-next;

}

printf(“\n\n”);

}

void menu()

{

printf(“\n 學生信息管理系統\n”);

printf(“\n 菜單\n\n”);

printf(“\n 1建立鏈表並顯示\n”);

printf(“\n 2查找某學號的學生信息\n”);

printf(“\n 3查找某姓名的學生信息\n”);

printf(“\n 4刪除某學號的學生信息\n”);

printf(“\n 5插入新的學生信息\n”);

printf(“\n 6按分數降序排列輸出\n”);

printf(“\n 7輸出\n”);

printf(“\n 0退出\n”);

printf(“\n 請選擇您要執行的選項:\n”);

}

c語言問題

#includestdio.h

/*函數功能:從鍵盤輸入一個班學生某門課的成績及其學號

當輸入成績為負值時,輸入結束

函數參數: 長整型數組num,存放學生學號

實型數組score,存放學生成績

函數返回值:學生總數

*/

int ReadScore(long num[],float score[])

{

int i,j,n=0;

printf(“please input students number:\n”);

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

{

scanf(“%d”,num[i]);

n=n+1;

}

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

{

printf(“please input No.%d student’s score:\n”,i+1);

for(j=0;j1;j++)

scanf(“%f”,score[j]);

}

return(n);

}

/*函數功能:統計不及格人數並列印不及格學生名單

函數參數:長整型數組num,存放學生學號

實型數組score,存放學生成績

整型變數n,存放學生總數

函數返回值:不及格人數

*/

int GetFail(long num[], float score[], int n)

{

int i,fail;

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

if(score[i]60)

{

printf(“the fail student number is:%d\n”,i);

fail=fail+1;

}

printf(“there are %d students failed:\n”,fail);

return (fail);

}

/*函數功能:計算全班平均分

函數參數:實型數組score,存放學生成績

整型變數n,存放學生總數

函數返回值:平均分

*/

float GetAver(float score[], int n)

{

float sum=score[0],aver;

int i;

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

{

sum=sum+score[i];

aver=sum/n;

}

printf(“the average score is %f\n”,aver);

return (aver);

}

/*函數功能:統計成績在全班平均分及平均分之上的學生人數並列印其學生名單

函數參數:長整型數組num,存放學生學號

實型數組score,存放學生成績

整型變數n,存放學生總數

函數返回值:成績在全班平均分及平均分之上的學生人數

*/

int GetAboveAver(long num[], float score[], int n)

{

int i,above=0;

float aver;

aver=GetAver(score,n);

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

if(score[i]=aver)

{

above=above+1;

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

printf(“%d”,num[i]);

}

printf(“there are %d students above the average\n”,above);

return(above);

}

/*函數功能:統計各分數段的學生人數及所佔的百分比

函數參數:實型數組score,存放學生成績

整型變數n,存放學生總數

函數返回值:無

*/

void GetDetail(float score[], int n)

{

int i,x=0,y=0,z=0,w=0;

float percent;

n=0;

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

if(score[i]=60score[i]70)

{

x=x+1;

percent=(float)(x/n);

printf(“there are %d students above 60\n”,x);

printf(“\n%f”,percent);

}

else if(score[i]=70score[i]80)

{

y=y+1;

percent=(float)(y/n);

printf(“there are %d students above 70\n”,y);

printf(“\n%f”,percent);

}

else if(score[i]=80score[i]90)

{

z=z+1;

percent=(float)(z/n);

printf(“there are %d students above 80\n”,z);

printf(“\n%f”,percent);

}

else if(score[i]=90score[i]100)

{

w=w+1;

percent=(float)(w/n);

printf(“there are %d students above 90\n”,w);

printf(“\n%f”,percent);

}

}

void main()

{

long num[5];

float score[5],aver;

int n=0,i,fail,above;

n=ReadScore(num,score);

aver=GetAver(score, n);

fail=GetFail(num, score,n=0);

above=GetAboveAver(num,score, n=0);

}

改到沒有語法錯誤了,不過邏輯有沒有錯誤就不知道了。主要在於函數里的行參不能賦值和強制轉換函數float 應寫為(float)i;而不能是float(i).

我是大一新生新學數組,編了一個計成績的C語言程序,看不懂程序錯在哪,請幫一下忙。謝謝!

10 行左右改成 int main()

7行左右改成:int GetAboveAver(int num[], float score[], int n, int);

47行左右改成:int GetFail(int* num, float * score,int n)

84行最優,改成:void GetDetail(float score[],int n)

114到120行 100後面沒百分號。

想想我大一的時候沒這麼勤奮啊,呵呵,加油啊。

原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/237291.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
小藍的頭像小藍
上一篇 2024-12-12 12:04
下一篇 2024-12-12 12:04

相關推薦

  • AES加密解密演算法的C語言實現

    AES(Advanced Encryption Standard)是一種對稱加密演算法,可用於對數據進行加密和解密。在本篇文章中,我們將介紹C語言中如何實現AES演算法,並對實現過程進…

    編程 2025-04-29
  • 學習Python對學習C語言有幫助嗎?

    Python和C語言是兩種非常受歡迎的編程語言,在程序開發中都扮演著非常重要的角色。那麼,學習Python對學習C語言有幫助嗎?答案是肯定的。在本文中,我們將從多個角度探討Pyth…

    編程 2025-04-29
  • Python被稱為膠水語言

    Python作為一種跨平台的解釋性高級語言,最大的特點是被稱為”膠水語言”。 一、簡單易學 Python的語法簡單易學,更加人性化,這使得它成為了初學者的入…

    編程 2025-04-29
  • OpenJudge答案1.6的C語言實現

    本文將從多個方面詳細闡述OpenJudge答案1.6在C語言中的實現方法,幫助初學者更好地學習和理解。 一、需求概述 OpenJudge答案1.6的要求是,輸入兩個整數a和b,輸出…

    編程 2025-04-29
  • Python按位運算符和C語言

    本文將從多個方面詳細闡述Python按位運算符和C語言的相關內容,並給出相應的代碼示例。 一、概述 Python是一種動態的、面向對象的編程語言,其按位運算符是用於按位操作的運算符…

    編程 2025-04-29
  • Java 監控介面返回信息報錯信息怎麼處理

    本文將從多個方面對 Java 監控介面返回信息報錯信息的處理方法進行詳細的闡述,其中包括如何捕獲異常、如何使用日誌輸出錯誤信息、以及如何通過異常處理機制解決報錯問題等等。以下是詳細…

    編程 2025-04-29
  • Python語言由荷蘭人為中心的全能編程開發工程師

    Python語言是一種高級語言,很多編程開發工程師都喜歡使用Python語言進行開發。Python語言的創始人是荷蘭人Guido van Rossum,他在1989年聖誕節期間開始…

    編程 2025-04-28
  • Python語言設計基礎第2版PDF

    Python語言設計基礎第2版PDF是一本介紹Python編程語言的經典教材。本篇文章將從多個方面對該教材進行詳細的闡述和介紹。 一、基礎知識 本教材中介紹了Python編程語言的…

    編程 2025-04-28
  • Python語言實現人名最多數統計

    本文將從幾個方面詳細介紹Python語言實現人名最多數統計的方法和應用。 一、Python實現人名最多數統計的基礎 1、首先,我們需要了解Python語言的一些基礎知識,如列表、字…

    編程 2025-04-28
  • Python作為中心語言,在編程中取代C語言的優勢和挑戰

    Python一直以其簡單易懂的語法和高效的編碼環境而著名。然而,它最近的發展趨勢表明Python的使用範圍已經從腳本語言擴展到了從Web應用到機器學習等廣泛的開發領域。與此同時,C…

    編程 2025-04-28

發表回復

登錄後才能評論