嗨首先這是我的計劃,我想我的程序中所有的輸出隔離在在C運輸及工務局局長問題++
列下面是我的程序的輸出現在我想使輸出爲全行在年齡和部分:
#include<iostream>
#include <iomanip>
using namespace std;
struct student {
string fullname[200];
string course[200];
int age[200];
};
student p1;
main()
{
int input;
cout<<"How many Student do you like to Add:";
cin>>input;
for(int i=0; i!=input; i++)
{
cout<<"----------Input #"<<i+1<<"----------"<<endl;
cout<<"Enter Name: ";
cin.ignore();
getline (cin,p1.fullname[i]);
cout<<"Enter Age: ";
cin>>p1.age[i];
cout<<"Enter Section: ";
cin>>p1.course[i];
}
cout<<"\n\n----------------- List of Student that is 19 Above -----------------"<<endl;
cout<<"\nFull Name:"<<setw(20)<<"Age:"<<setw(20)<<"Section:"<<endl;
for(int i=0; i!=input; i++)
{
if(p1.age[i] >= 19)
{
cout<<p1.fullname[i]<< setfill(' ') <<setw(20) <<p1.age[i]<< setfill(' ') <<setw(20)<<p1.course[i]<<endl;
}
}
system("PAUSE");
}
歡迎。請看[問]。 –