08.08.2009, 20:19. Просмотров 574. Ответов 3
задача взята из учебника Дейтел Х. Как програмировать на С++ рис 6.1
вроде все набрал правильно но выдает ошибки
вот код:
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| #include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <iomanip>
#include <conio.h>
using namespace std;
struct Time{
int hour;
int minute;
int second;
};
void printMilitary(const Time &t);
void printStandart(const Time &t);
int _tmain(int argc, _TCHAR* argv[])
{
SetConsoleOutputCP(1251);
Time dinnerTime;//Переменная нового типа Time
dinnerTime.hour = 18;
dinnerTime.minute = 30;
dinnerTime.second = 0;
cout<<"hg :\n\n";
printMilitary(dinnerTime);
cout<<"hg :\n\n";
printStandart(dinnerTime);
cout<<"\n\n";
return 0;
}
void printMilitary(const Time &t){
cout<<(t.hour<10?"0":"")<<t.minute
<<":"<<(t.minute<10?"0":"")<<t.minute
<<":"<<(t.second<10?"0":"")t.second<<t.second;
}
void printStandart(const Time &t){
cout<<((t.hour==0||t.hour==12)?12:t.minute%12)
<<":"<<(t.minutet.second < 10 ? "0" : "")<<t.minute
<<":"<<(t.second<10?"0":"")t.second<<t.second
<<(t.hour<12&"AM":"PM");
} |
|