亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

求大神修改

求大神修改

C
慕移動9341187 2015-12-11 11:12:02
#include<stdio.h>#define N 40int ReadScore(int score[],long num[]);void DataSort(int score[],long num[],int n);void printfscore(int score[],long num[],int n);int main(){? ? int n,score[N];? ? long num;? ? ReadScore(score,num);? ? printf("Total students'ID and students are %d\n",num,n);? ? DataSort(score,num,n);? ? printf("Sorted score:");? ? printfscore(score,num,n);? ? return 0;}int ReadScore(int score[],long num[]){? ? int i=-1;? ? do? ? {? ? ? ? i++;? ? ? ? printf("Input students'ID and score:");? ? ? ? scanf("%ld%d",&num[i],&score[i]);? ? }while(score[i]>=0&&num[i]>0);? ? return i;}void DataSort(int score[],long num[],int n){? ?int i,j,k;? ?int temp1;? ?long temp2;? ?for(i=0;i<n-1;i++)? ?{? ? ? ?k=i;? ? ? ?for(j=i+1;j<n;j++)? ? ? ?{? ? ? ? ? ?k=j;? ? ? ?}? ? ? ?if(k!=1)? ? ? ?{? ? ? ? ? ?temp1=score[k];score[i]=score[k];score[i]=temp1;? ? ? ? ? ?temp2=num[k];num[k]=num[j];num[j]=temp2;? ? ? ?}? ?}}void printfscore(int score[],long num[],int n){? ? int i;? ? for(i=1;i<n;i++)? ? {? ? ? ? printf("%ld%d\n",num[i],score[i]);? ? }? ? printf("\n");}
查看完整描述

2 回答

已采納
?
流浪_老

TA貢獻71條經驗 獲得超14個贊

#include<stdio.h>

#define N 40

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

void DataSort(int score[],long num[],int n);

void printfscore(int score[],long num[],int n);

int main()

{

? ? int n,score[N];

? ? long num[N];

? ? ReadScore(score,num);

? ? printf("Total students'ID and students are %d\n",num,n);

? ? DataSort(score,num,n);

? ? printf("Sorted score:");

? ? printfscore(score,num,n);

? ? return 0;

}

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

{

? ? int i=-1;

? ? do

? ? {

? ? ? ? i++;

? ? ? ? printf("Input students'ID and score:");

? ? ? ? scanf("%ld%d",&num[i],&score[i]);


? ? }while(score[i]>=0&&num[i]>0);

? ? return i;

}

void DataSort(int score[],long num[],int n)

{

? ?int i,j,k;

? ?int temp1;

? ?long temp2;

? ?for(i=0;i<n-1;i++)

? ?{

? ? ? ?k=i;

? ? ? ?for(j=i+1;j<n;j++)

? ? ? ?{

? ? ? ? ? ?k=j;

? ? ? ?}

? ? ? ?if(k!=1)

? ? ? ?{

? ? ? ? ? ?temp1=score[k];score[i]=score[k];score[i]=temp1;

? ? ? ? ? ?temp2=num[k];num[k]=num[j];num[j]=temp2;

? ? ? ?}


? ?}



}


void printfscore(int score[],long num[],int n)

{

? ? int i;

? ? for(i=1;i<n;i++)

? ? {

? ? ? ? printf("%ld%d\n",num[i],score[i]);

? ? }

? ? printf("\n");

}


查看完整回答
反對 回復 2015-12-11
?
Jason333

TA貢獻31條經驗 獲得超0個贊

long num; ?改成 long num[N];?

查看完整回答
反對 回復 2015-12-11
  • 2 回答
  • 0 關注
  • 2055 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號