#include "stdafx.h"
#include <iostream>
#include<conio.h>
using namespace std;
class time
{
private:
int hour;
int min;
public:
void gettime(int h, int m)
{
hour = h;
min = m;
}
void putdata()
{
cout<< hour << ": " << min<<"\n";
}
void addtime(time t1, time t2)
{
min = t1.min + t2.min;
hour = min / 60;
min = min % 60;
hour = hour + t1.hour + t2.hour;
}
};
void main()
{
time t1, t2, t3;
t1.gettime(22, 45);
t2.gettime(33, 55);
t3.addtime(t1, t2);
cout << "time 1 : ";
t1.putdata();
cout << "time 2 : ";
t2.putdata();
cout << "time 3 : ";
t3.putdata();
_getch();
}
#include <iostream>
#include<conio.h>
using namespace std;
class time
{
private:
int hour;
int min;
public:
void gettime(int h, int m)
{
hour = h;
min = m;
}
void putdata()
{
cout<< hour << ": " << min<<"\n";
}
void addtime(time t1, time t2)
{
min = t1.min + t2.min;
hour = min / 60;
min = min % 60;
hour = hour + t1.hour + t2.hour;
}
};
void main()
{
time t1, t2, t3;
t1.gettime(22, 45);
t2.gettime(33, 55);
t3.addtime(t1, t2);
cout << "time 1 : ";
t1.putdata();
cout << "time 2 : ";
t2.putdata();
cout << "time 3 : ";
t3.putdata();
_getch();
}
0 التعليقات:
إرسال تعليق