仰望星辉😳 陈梦强
也许我们本来就另一个世界
关注数: 1 粉丝数: 12 发帖数: 261 关注贴吧数: 7
简单的  偶是菜鸟,帮帮忙~~~~~~~~~~ 环境   TUBE2.0程序:#include #define LENGTH 4main(){ void Input(float array[],int); void Screen(float array[],int); void Output(float array[],int); float wuli[LENGTH+1]; float gaoshu[LENGTH+1]; float Sum[LENGTH+1]; float Average[LENGTH+1]; int counter; int choice; int choice1,choice2,choice3; printf("\n Warning: You should inout your date before you use it!Or your date is 0!"); for(counter=0;counter<=LENGTH;counter++){ wuli[counter]=0; gaoshu[counter]=0; } while(1){ printf("\nInput-----1;\nScreen-----2;\nOutput-----3;\nExit-----4.\n"); printf("Please enter your choice:"); scanf("%d",&choice); if(choice==1){ while(1){ printf("\n Choose the subject :\nwuli-----1;\ngaosghu-----2;\nExit-----3;\n"); printf("\n Enter you choice:\n"); scanf("%d",&choice1); if(choice1==1){ printf("\nwuli\n"); Input(wuli,LENGTH); } else if(choice1==2){ printf("\ngaoshu\n"); Input(gaoshu,LENGTH); } else{ break; } } } else if(choice==2){ for(counter=0;counter<=LENGTH;counter++){ Sum[counter]=wuli[counter]+gaoshu[counter]; Average[counter]=(wuli[counter]+gaoshu[counter])/2.0; } while(1){ printf("\nwuli-----1;\ngaoshu-----2;\nSum-----3;\nAverage-----4;\nExit-----5.\n"); printf("\n Enter your choose :"); scanf("%d",&choice2); if(choice2==1){ printf("\nScreen wuli\n"); Screen(wuli,LENGTH); } else if(choice2==2){ printf("\nScreen gaoshu\n"); Screen(gaoshu,LENGTH); } else if(choice2==3){ printf("\nScreen Sum\n"); Screen(Sum,LENGTH); } else if(choice2==4){ printf("\nScreen Average\n"); Screen(Average,LENGTH); } else{ break; } } } else if(choice==3){ while(1){ printf("\n OutPut\nwuli-----1;\ngaoshu-----2;\nSum-----3;\nAverage-----4;\nExit-----5.\n"); printf("Enter your choice:"); scanf("%d",&choice3); if(choice3==1){ printf("\nOutput wuli\n"); Output(wuli,LENGTH); } else if(choice3==2){ printf("\nOutput gaoshu\n"); Output(gaoshu,LENGTH); } else if(choice3==3){ printf("\nOutput Sum\n"); Output(Sum,LENGTH); } else if(choice3==4){ printf("\nOutput Average\n"); Output(Average,LENGTH); } else{ break; } } } else{ break; } }}void Input(float array[],int length){ int counter; for(counter=1;counter<=length;counter++){ printf("\nPlease enter the date of NUMBER %d:",counter); scanf("%f3.1",&array[counter]); }}void Screen(float array[],int length){ int counter; for(counter=1;counter<=length;counter++){ printf("\n NUMBER %d-----%3.1f",counter,array[counter]); }}void Output(float array[],int length){ float temp[LENGTH+1]; float index[LENGTH+1]; int n=1; int m,UpLimit,counter; float max; float copy[LENGTH+1]; for(counter=0;counter<=length;counter++){ copy[counter]=array[counter]; } for(UpLimit=length;UpLimit>0;UpLimit--){ max=0; for(counter=1;counter<=length;counter++){ if(copy[counter]>max){ m=counter; max=copy[counter]; } } temp[n]=max; index[n]=m; n++; copy[m]=0; } for(counter=1;counter<=LENGTH;counter++){ printf("\n%d-----%3.1f",index[counter],temp[counter]); }}为什么最后的OUTPUT函数显示出来的都是0?晕死拉!
1 下一页