精華區beta NTUCH-HW 關於我們 聯絡資訊
功能 用到的觀念 CODE #include<iostream>//header file #include<iomanip> #include<cmath> using namespace std; using std::setw; using std::fixed; using std::setprecision; #include<string> using std::string; using std::getline; int main() { int numgrades,i; double sum=0,ave=0,temp; cout << "Enter the total day of the month "; cin >> numgrades; double *grade = new double[numgrades]; // create the array for(i=0;i<numgrades;i++) { cout<<i+1<<" "; cin>>grade[i]; sum=sum+grade[i]; ave=sum/numgrades; } for(int j=0;j<numgrades-1;j++) { if(grade[j+1]<grade[j]) { temp=grade[j+1]; grade[j+1]=grade[j]; grade[j]=temp; } } cout<<"the average "<<ave<<endl; cout<<"max "<<grade[numgrades-1]<<endl; cout<<"min "<<grade[0]<<endl; system("pause"); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.7.59