222222222222222222222222
#include <iostream>
#include <string>
using namespace std;
void count(string str,/**1**/int &n1,int &n2,int &n3,int &n4,int &n5 /**/)
{
int i=0;
n1=n2=n3=n4=n5=0;
/**2************found****************/
for(string::iterator itr=str.begin();itr!=str.end();++itr)
{
if(*itr>='0'&&*itr<='9') ++n1;
else if(*itr>='A'&&*itr<='Z') ++n2;
else if(*itr>='a'&&*itr<='z') ++n3;
else if(*itr==' ') ++n4;
else ++n5;
}
}
void main()
{ int n1,n2,n3,n4,n5;
string str1;
//cout<<"input str1:";
/**3************found****************/
getline(cin,str1,'#');
count(str1,n1,n2,n3,n4,n5);
cout<<"n1="<<n1<<" n2="<<n2<<" n3="<<n3<<" n4="<<n4<<" n5="<<n5<<endl;
}
33333333333333333
#include <iostream>
#include <string>
using namespace std;
void count(string str,/**1**/int &n1,int &n2,int &n3,int &n4,int &n5 /**/)
{
int i=0;
n1=n2=n3=n4=n5=0;
/**2************found****************/
for(string::iterator itr=str.begin();itr!=str.end();++itr)
{
if(*itr>='0'&&*itr<='9') ++n1;
else if(*itr>='A'&&*itr<='Z') ++n2;
else if(*itr>='a'&&*itr<='z') ++n3;
else if(*itr==' ') ++n4;
else ++n5;
}
}
void main()
{ int n1,n2,n3,n4,n5;
string str1;
//cout<<"input str1:";
/**3************found****************/
getline(cin,str1,'#');
count(str1,n1,n2,n3,n4,n5);
cout<<"n1="<<n1<<" n2="<<n2<<" n3="<<n3<<" n4="<<n4<<" n5="<<n5<<endl;
}
444444444444444444444
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class Date
{
public:
int year;
int month;
int day;
Date():year(0),month(0),day(0){}
Date(int year,int month,int day);
friend istream & operator>>(istream &in,Date &d)
{ in>>d.year>>d.month>>d.day;
return in;
}
friend ostream & operator<<(ostream &out,Date &d)
//**2** **********found**********
{
out<<setfill('0')
<<d.year<<"-"<<setw(2)<<d.month<<"-"<<setw(2)<<d.day
<<setfill(' ');
return out;
}
/*****************************/
};
Date::Date(int year,int month,int day) //Date构造函数实现
//**1** **********found**********
{
this->year=year;
this->month=month;
this->day=day;
}
/*****************************/
class Person
{
protected:
string idcardno; //身份证号
string name; //姓名
Date birthdate; //出生日期
string ismale; //性别
public:
Person( string pid, string pname, Date pdate, string pmale);
string getIDCardNO()const{ return idcardno; }
const string getName()const{ return name; }
void rename(string new_name);
Date getBirthDate()const{ return birthdate; }
string isMale()const{ return ismale;}
friend ostream & operator<<(ostream &out,Date &d)
{ out<<d.year<<'-'<<d.month<<'-'<<d.day<<"\n";
return out;
}
};
class Staff: public Person
{
string department; //工作部门
double salary; //工资
public:
Staff( string id_card_no, string p_name, Date birth_date, string is_male,
string dept, double sal);
const string getDepartment()const{ return department; }
void setDepartment(string dept);
double getSalary()const{ return salary; }
void setSalary(double s){ salary=s; }
void show()
{
//cout<<idcardno<<endl;
cout<<name<<endl; //姓名
cout<<birthdate<<endl; //出生日期
cout<<ismale<<endl; //性别
cout<<department<<endl;
cout<<salary<<endl;
}
};
Person::Person(string id_card_no, string p_name, Date birth_date, string is_male)
//**3** **********found**********
{
idcardno=id_card_no;
name=p_name;
birthdate.year=birth_date.year;
birthdate.month=birth_date.month;
birthdate.day=birth_date.day;
ismale=is_male;
}
/*****************************/
Staff::Staff(string id_card_no, string p_name, Date birth_date, string is_male, string dept, double sal)
//**4** **********found**********
:Person(id_card_no,p_name,birth_date,is_male)
{
department=dept;
salary=sal;
}
/*****************************/
void Staff::setDepartment(string dept)
{
department=dept;
}
int main()
{
string idcardno; //身份证号
string name; //姓名
Date birthdate; //出生日期
string sex; //性别
string department; //工作部门
double salary; //工资
//**读入职工信息 身份证、姓名、出生日期、性别、部门、工资****//
cin>>idcardno;
while(idcardno.length()!=18)
{ cout<<"输入身份证必须是18位"/";cin>>idcardno;}
cin>>name>>birthdate>>sex>>department>>salary;
Staff st(idcardno,name,birthdate,sex,department,salary);
st.show();
return 0;
}
555555555555
#include <iostream>
#include <string>
using namespace std;
class MyPoint{ //表示平面坐标系中的点的类
double x;
double y;
public:
MyPoint (double x,double y)
{//**1** **********found**********
this->x=x;
this->y=y;
/*************************/
}
double getX()const{ return x;}
double getY()const{ return y;}
friend ostream & operator<<(ostream &out,MyPoint &p)
{ out<<'('<<p.x<<','<<p.y<<")\n";
return out;
}
};
class MyRectangle{ //表示矩形的类
MyPoint up_left; //矩形的左上角顶点
MyPoint down_right; //矩形的右下角顶点
public:
MyRectangle(MyPoint upleft,MyPoint downright);
MyPoint getUpLeft()const{ return up_left;} //返回左上角坐标
MyPoint getDownLeft()const; //返回左下角坐标
MyPoint getDownRight()const{ return down_right;} //返回右下角坐标
MyPoint getUpRight()const; //返回右上角坐标
double area()const; //返回矩形的面积
friend ostream & operator<<(ostream &out,MyRectangle &R)
{ out<<R.getUpLeft()<<endl;//输出左上角坐标
out<<R.getDownLeft()<<endl;//输出左下角坐标
out<<R.getDownRight()<<endl; //输出右下角坐标
out<<R.getUpRight()<<endl;//输出右上角坐标
out<<R.area()<<endl; //输出矩形的面积
return out;
}
};
//**2** **********found**********
MyRectangle::MyRectangle(/**/ /**/):
/**/ /**/{}
MyPoint MyRectangle::getUpRight()const
{
//**3** **********found**********
/**********************************/
}
MyPoint MyRectangle::getDownLeft()const
{//**4** **********found**********
/**********************************/
}
//**5** **********found**********
/**********************************/
{
return (getUpLeft().getX()-getDownRight().getX())*
(getDownRight().getY()-getUpLeft().getY());
}
int main( )
{
int x1,y1,x2,y2;
//注意读入数据满足(x1,y1 )为矩形左上角顶点,(x2,y2)为矩形右下角顶点//
cin>>x1>>y1>>x2>>y2;
MyRectangle r(MyPoint(x1,y1),MyPoint(x2,y2));
cout<<r;
return 0;
}