Сложение английских тугриков. :)

//------------------------------------------------------------------------------------------------
#include <iostream>
#include <conio.h>
using namespace std;
//--------------------------------
struct sterling
{
int feet;
int shil;
int pens;
};
//----------------------------------
sterling single(sterling, sterling);
void single(sterling);
//------------------------------------
int main()
{
sterling money1, money2;
char ch='/';
cout<<"Enter ferst summ in formate [funt/shillin/pens]: ";
cin>>money1.feet>>ch>>money1.shil>>ch>>money1.pens;
cout<<"Enter second summ in same format: ";
cin>>money2.feet>>ch>>money2.shil>>ch>>money2.pens;
sterling money3 = single(money1, money2);
single(money3);
getch();
return 0;
}
//---------------------------------------------------------
sterling single(sterling m1, sterling m2)
{
unsigned long a = m1.feet*240 + m1.shil*12 + m1.pens;
unsigned long b = m2.feet*240 + m2.shil*12 + m2.pens;
unsigned long c = a + b;
sterling summa;
summa.feet = c/240;
summa.shil = (c%240)/12;
summa.pens = c - summa.feet*240 - summa.shil*12;
return summa;
}
//-------------------------------------------------------
void single (sterling m3)
{
cout<<"Itogovaya summa: "<<m3.feet<<'/'<<m3.shil<<'/'<<m3.pens;
}

//------------------------------------------------------------------------------------------------

Хакинг | Главная | Программирование

Hosted by uCoz