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

要怎麼寫輸入任意八個數去比較大小的程式呢,要如何寫呢?請大家幫幫忙一下

2006-12-03 12:07:02 · 3 個解答 · 發問者 恰恰 1 in 電腦與網際網路 程式設計

3 個解答

#include
#include
#include
#include
#include
#include
#include

using namespace std;

int main(void)
{

int num;
cout<<"how many number which you want to key in :";
cin>>num;

int *num_array = new int[num];

for(int i=0; i {
cout<<"please key in the no."< cin>>num_array[i];
}

vector array1(num_array,num_array+num);
sort(array1.begin(),array1.end());

int max = *( array1.end() - 1 );
int min = *( array1.begin() );

cout<<"max = "< cout<<"min = "<
delete []num_array;
system("pause");
return 0;
}

2006-12-04 12:17:33 · answer #1 · answered by 小梁 3 · 0 0

#include
using namespace std;

int main()
{ const
int num=8;
int in[num];
for(int i=0;i cin>>in[i];}
for(int j=0;j for(int k=j+1;k if(in[j] int out=in[j];
in[j]=in[k];
in[k]=out;
}
}
}
for(int s=0;s cout< if(s cout<<'>';}
}
return 0;
}

2006-12-04 17:05:04 補充:
第四行的是同一行const int num=8;

2006-12-04 12:01:45 · answer #2 · answered by Oo瞇瞇眼oO 1 · 0 0

//Power by Microsoft Visual Studio 2005//可以使用 Dev-C++ 編譯此程式#include#include#define LENGTH 8using namespace std;int main(int argc,char **argv){ //=====START=====// void resort(int LEN,int *NUM); int i,number[LENGTH]; for(i=0;i*(NUM+j)){    temp=*(NUM+i);    *(NUM+i)=*(NUM+j);    *(NUM+j)=temp;   }  } }}

2006-12-03 13:06:33 · answer #3 · answered by Big_John-tw 7 · 0 0

fedest.com, questions and answers