lab 2

 

 

 

#include<iostream>

using namespace std;

struct Time
{
   int year,month,date,hour,minute,second; 
}time;

int main()
{
	cout<<"请输入年,月,日,时,分,秒"<<endl;
	cout<<"年:"<<endl;cin>>time.year;
	cout<<"月:"<<endl;cin>>time.month;
	cout<<"日:"<<endl;cin >>time.date;
	cout<<"时:"<<endl;cin >>time.hour;
	cout<<"分:"<<endl;cin >>time.minute;
	cout<<"秒:"<<endl;cin >>time.second ;

    cout<<time.year <<"年 "<<time.month<<"月 "<<time.date <<"日 "<<time.hour <<"时 "<<time.minute <<"分 "<<time.second <<"秒"<<endl;
	return 0;
}


 

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
	char ball[5][20]={"redBall","yellowBall","blueBall","whiteBall","blackBall"};
    int i,j,k;
	int count=0;
	for(i=0;i<5;i++)
	{
	    for(j=i+1;j<5;j++)
		{
		    for(k=j+1;k<5;k++)
			{
				count++;
				cout<<left<<setw(15)<<ball[i]<<setw(15)<<ball[j]<<setw(15)<<ball[k]<<endl;
			}
		}
	}
    cout<<"一共有"<<count<<"种."<<endl;
return 0;
}


 

#include<fstream>
using namespace std;

int main() 
{
    ifstream infile;
    ofstream outfile;
    int income, tax;
    infile.open("date.txt");
    outfile.open("small.txt");
	outfile.open("big.txt");
    while (infile >> income) 
	{
        if ( income < 100 )
          outfile<<small<<endl;
        else
          
        outfile<<big<<endl;
	}
    infile.close();
    outfile.close();
    return 0;
}


 

你可能感兴趣的:(lab 2)