第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

結(jié)構(gòu)體設(shè)計(jì)出錯(cuò),不知錯(cuò)在哪,求大神指導(dǎo),謝謝?。。?/h1>

原題,完成校際運(yùn)動(dòng)會(huì)成績(jī)管理功能,包括輸入比賽項(xiàng)目event及參賽學(xué)校名字name,輸入比賽成績(jī)score,參賽選手名字person,項(xiàng)目名次rank,計(jì)算總分sum,其中,sum為score加上項(xiàng)目的加分。 各項(xiàng)目名次取法有如下幾種:項(xiàng)目一:取前5名:第1名得分7,第2名得分5,第3名得分3,第4名得分2,第5名得分1;其余名次不加分。項(xiàng)目二:取前3名:第1名得分5,第2名得分3,第3名得分2;其余名次不加分。輸出第一所學(xué)校的score和sum。#include<stdio.h>#include<stdlib.h>#include<string.h>#define LEN sizeof(struct School)struct School{int event;?char name[20];?int? score;?char person[20];?int rank;?int sum;?struct School *next;};static int n;struct School *creat(void){struct School *head;?struct School *p1,*p2,*a[100];?n=0;?p1=p2=(struct School *)malloc(LEN);?head=NULL;?while(p1->event!=0)?{n=n+1;? if(n==1)a[0]=head=p1;? else p2->next=p1;? p2=p1;? p1=(struct School *)malloc(LEN);? printf("the event is:(put 0 end the putting of school):");? scanf("%d",&p1->event);? printf("school name:");? getchar();? gets(p1->name);? printf("school score:");? scanf("%d",&p1->score);? printf("person name:");? getchar();? gets(p1->person);? printf("school rank:");? scanf("%d",&p1->rank);? switch(p1->event)? {case 0:p1->sum=p1->score;break;?? case 1:??? {switch(p1->rank)???? {case 1:p1->sum=p1->score+7;break;????? case 2:p1->sum=p1->score+5;break;????? case 3:p1->sum=p1->score+3;break;????? case 4:p1->sum=p1->score+2;break;????? case 5:p1->sum=p1->score+1;break;????? default:p1->sum=p1->score;}}break;?? case 2:????? {switch(p1->rank)????? {case 1:p1->sum=p1->score+5;break;?????? case 2:p1->sum=p1->score+3;break;?????? case 3:p1->sum=p1->score+2;break;?????? default:p1->sum=p1->score;}}break;??? default:p1->sum=p1->score;? }? }? p2->next=NULL;? return(a[0]);??? }int main(){struct School *pt;pt=creat();printf("\nscore:%d\nsum:%d\n",pt->score,pt->sum);??? return 0;}輸入的score是123,event 為1,rank為1.輸出的score總是一個(gè)很大的數(shù)據(jù)15564562,輸出的sum 也很大,11235578.求教為什么?
查看完整描述

2 回答

已采納
?
BlueCitizen

TA貢獻(xiàn)5條經(jīng)驗(yàn) 獲得超0個(gè)贊

哦,能進(jìn)入循環(huán),我說錯(cuò)了,抱歉。while(p1->event!=0)對(duì)于這個(gè)入口循環(huán),event并沒有賦值,那么系統(tǒng)會(huì)隨機(jī)給一個(gè)值,給什么樣的值看運(yùn)氣,一般會(huì)很大。

查看完整回答
反對(duì) 回復(fù) 2015-11-22
  • 級(jí)數(shù)
    級(jí)數(shù)
    大神非常感謝!
  • 級(jí)數(shù)
    級(jí)數(shù)
    如果寫完鏈表,我要設(shè)計(jì)一個(gè)函數(shù)能夠查找輸出鏈表里面第i個(gè)結(jié)構(gòu)體,怎么辦?i是變量,根據(jù)前面的函數(shù),鏈表中有n個(gè)結(jié)構(gòu)體。
  • BlueCitizen
    BlueCitizen
    用for循環(huán)來(lái)計(jì)數(shù)就可以了
?
BlueCitizen

TA貢獻(xiàn)5條經(jīng)驗(yàn) 獲得超0個(gè)贊

最開始沒有賦值,無(wú)法進(jìn)入循環(huán)。另外最好加一些注釋,這樣看著很亂

查看完整回答
反對(duì) 回復(fù) 2015-11-21
  • 2 回答
  • 0 關(guān)注
  • 1754 瀏覽
慕課專欄
更多

添加回答

了解更多

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)