English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

宣告三個浮點數陣列fa[5],fb[5]及fc[5],輸入fa[]及fb[]的數值,令fc[i]=fa[i]+fb[i],
找出fc[]陣列之最大值.

2007-03-17 20:16:28 · 1 個解答 · 發問者 夜生活 1 in 電腦與網際網路 程式設計

1 個解答




//Power by Visual Studio 2005

#include

#include

#define RANGE 5

double SORT(double *NUM, int LEN){

int i,j;

double temp;

for(i=0;i
for(j=i;j
if(*(NUM+j)>*(NUM+i)){

temp=*(NUM+i);

*(NUM+i)=*(NUM+j);

*(NUM+j)=temp;

}

return *(NUM+0);

}

void INPUT(double *NUM){

int i;

for(i=0;i
printf("Input %d number: ",i+1);

scanf("%lf",(NUM+i));

}

}

int main(int argc, char* argv[]){

//==========START==========//

int i;

double fa[RANGE],fb[RANGE],fc[RANGE];

printf("Input fa ...\\n");

INPUT(fa);

printf("Input fb ...\\n");

INPUT(fb);

for(i=0;i
*(fc+i)=*(fa+i)+*(fb+i);

}

printf("Maximum: %lf\\n",SORT(fc, RANGE));

//==========END==========//

system("PAUSE");

return 0;

}



2007-03-18 01:04:19 · answer #1 · answered by Big_John-tw 7 · 0 0

fedest.com, questions and answers