自考新教材-p301_5(1)
源程序:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class student
{
private:
	string name1;
	float score1;
public:
	int i;
	student(string na, float sc)
	{
			name1=na;
			score1 = sc;
	}
	void output()
	{
		cout << setw(10) << left << name1;
		cout << setw(10) << right << score1 << endl;
	}
};
int main()
{
	string name;
	float score;
	for (int i = 0; i < 3; i++)
	{
		cin >> name >> score;
		student stud(name, score);
		stud.output();
	}
	system("pause");
	return 1;
}
运行结果:

 
                    
                     
                    
                 
                    
                
 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号