level 9
#include<iostream>
using namespace std;
class Date;
class Time
{
public:
Time(int,int,int);
void display(Date&);
private:
int hour;
int minute;
int sec;
};
class Date
{
public:
Date(int,int,int);
friend void Time::display(Date&);
private:
int month;
int day;
int year;
};
Time::Time(int h,int m,int s)
{
hour=h;
minute=m;
sec=s;
}
void Time::display(Date&d)
{
cout<<d.month<<"/"<<d.day<<"/"<<d.year<<endl;
cout<<hour<<":"<<minute<<":"<<sec<<endl;
}
Date::Date(int m,int d,int y)
{
month=m;
day=d;
year=y;
}
int main()
{
Time ti(10,13,56);
Date d1(12,25,2004);
ti.display(d1);
return 0;
}
2015年04月16日 02点04分
1
level 9
#include<iostream>
using namespace std;
template<class numtype>
class Compare
{
public:
Compare(numtype a,numtype b)
{
x=a;y=b;
}
numtype max();
numtype min();
private:
numtype x,y;
};
template<class numtype>
numtype Compare<numtype>::max()
{
return (x>y)?x:y;
}
template<class numtype>
numtype Compare<numtype>::min()
{
return (x<y)?x:y;
}
int main()
{
Compare<int>cmp1(3,7);
cout<<cmp1.max()<<" is the Maximum of two integer numbers."<<endl;
cout<<cmp1.min()<<" is the Minimum of two integer numbers."<<endl<<endl;
Compare<float>cmp2(45.78,93.6);
cout<<cmp2.max()<<" is the Maximum of two float numbers."<<endl;
cout<<cmp2.min()<<" is the Minimum of two float numbers."<<endl<<endl;
Compare<char>cmp3('a','A');
cout<<cmp3.max()<<" is the Maximum of two char numbers."<<endl;
cout<<cmp3.min()<<" is the Minimum of two char numbers."<<endl<<endl;
return 0;
}
2015年04月16日 02点04分
2
level 9
#include <iostream>
#include <string>
using namespace std;
class Student
{
public:
void get_value();
protected:
int num;
string name;
char sex;
};
class Student1:protected Student
{
public:
void get_value1();
void display1();
private:
int age;
string addr;
};
void Student::get_value()
{
cin>>num>>name>>sex;
}
void Student1::get_value1()
{
get_value();
cin>>age>>addr;
}
void Student1::display1()
{
cout<<"num: "<<num<<endl;
cout<<"name: "<<name<<endl;
cout<<"sex: "<<sex<<endl;
cout<<"age: "<<age<<endl;
cout<<"address: "<<addr<<endl;
}
int main()
{
Student1 stud1;
stud1.get_value1();
stud1.display1();
return 0;
}
2015年04月28日 06点04分
3
level 9
#include <iostream>
#include <string>
using namespace std;
class Teacher
{
public:
void get_value1();
void display1();
protected:
string name;
int age;
char sex;
string addr;
int tele;
string title;
};
class Cadre
{
public:
void get_value2();
string post;
protected:
string name;
int age;
char sex;
string addr;
int tele;
};
class Teacher_Cadre:public Teacher,public Cadre
{
public:
void get_value3();
void show();
private:
int wages;
};
void Teacher::get_value1()
{
cin>>name>>age>>sex>>addr>>tele>>title;
}
void Cadre::get_value2()
{
cin>>post;
}
void Teacher_Cadre::get_value3()
{
cin>>wages;
}
void Teacher::display1()
{
cout<<"name: "<<name<<endl;
cout<<"age: "<<age<<endl;
cout<<"sex: "<<sex<<endl;
cout<<"address: "<<addr<<endl;
cout<<"telephone: "<<tele<<endl;
cout<<"title: "<<title<<endl;
}
void Teacher_Cadre::show()
{
display1();
cout<<"post: "<<post<<endl;
cout<<"wages: "<<wages<<endl;
}
int main()
{
Teacher_Cadre t1;
t1.get_value1();
t1.get_value2();
t1.get_value3();
t1.show();
return 0;
}
2015年04月28日 06点04分
4
level 9
#include<iostram>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>tj,boss;
int n,m;
int main()
{
while(cin>>n&&n)
{
for(int i=1;i<=n;i++)
{
cin>>m;
tj.push_back(m);
}
for(int i=1;i<=n;i++)
{
cin>>m;
boss.push_back(m);
}
sort(tj.begin(),tj.end());
sort(boss.begin(),boss.end());
}
}
2015年05月14日 12点05分
5
level 9
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct t
{
int start;
int end;
int flag;
};
bool mycomp(t x,t y)
{
if(x.end==y.end) return x.start<y.start;
return x.end<y.end;
}
bool mycomp1(t x,t y)
{
if(x.start==y.start) return x.end<y.end;
return x.start<y.start;
}
int main()
{
int n,coun,p,temps,tempe;
int m;
cin>>m;
while(m--)
{
cin>>n;
t k[405];
coun=0;
for(int i=0;i<n;i++)
{
cin>>k[i].start>>k[i].end;
if(k[i].start>k[i].end)
{
p=k[i].start;
k[i].start=k[i].end;
k[i].end=p;
}
k[i].flag=0;
}
sort(k,k+n,mycomp);
for(int i=0;i<n;i++)
{
if(k[i].flag==0)
{
temps=k[i].start;
tempe=k[i].end;
sort(k+i,k+n,mycomp1);
for(int j=i;j<n;j++)
{
if(((k[j].start+1)/2>(tempe+1)/2)&&k[j].flag==0)
{
k[j].flag=1;
temps=k[j].start;
tempe=k[j].end;
}
}
coun++;
}
}
cout<<coun*10<<endl;
}
return 0;
}
2015年05月14日 12点05分
6
level 1
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int m,n,k,h,l;
while(cin>>m>>n)
{
k=0;
h=0;
l=0;
int a[1005][1005];
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>a[m][n];
if(abs(a[m][n])>k)
{
k=a[m][n];
h=m;
l=n;
}
}
}
cout<<h<<" "<<l<<" "<<k<<endl;
}
return 0;
}
2015年07月13日 02点07分
7