Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<ctime>
- #include<string.h>
- #include<stdlib.h>
- #include<conio.h>
- using namespace std;
- class TimeZone //타임설정및출력
- {
- public:
- TimeZone() //기본시간 및 시스템시간
- {
- timenow = time(0);
- tmp = timenow / 86400;
- s = timenow%60;
- m = (timenow/60)-(timenow/3600*60);
- h = (timenow/3600)-(tmp*24);
- bh = ((timenow+32400)/3600)-(tmp*24);
- }
- int timenow; int tmp;
- int s; int m; int h;
- int bm; int bh;
- void process(int select)
- {
- char city[20]; //시티이름
- switch(select) //입력값에 따라 시간을 더하고 문자열저장.
- {
- case 1: h+=9; strcpy(city,"서울/도쿄"); break;
- case 2: h-=5; strcpy(city,"뉴욕"); break;
- case 3: strcpy(city,"런던"); break;
- case 4: h+=8; strcpy(city,"시드니"); break;
- default: break;
- }
- output(city); //출력
- return;
- }
- void output(char *city) //출력
- {
- system("cls");
- if(h>=24) h-=24;
- system("cls");
- cout<<"컴퓨터시간 : "<<bh<<":"<<m<<":"<<s<<endl;
- cout<<city<<"시간 : "<<h<<":"<<m<<":"<<s<<endl;
- cout<<"계속하시려면 아무키나 누르세요."<<endl;
- getch(); //아무값이나 입력받으면 나옴.
- }
- };
- int main(void)
- {
- while(1)
- {
- TimeZone tz; //Class초기화
- system("cls");
- int select;
- cout<<"초간단 세계시간출력 프로그램"<<endl;
- cout<<"1)서울/도쿄 2)뉴욕 3)런던 4)시드니 5)[종료]"<<endl;
- cout<<"Input : ";
- cin>>select; //값입력
- if(select==5) break; //입력값이 5면 while나옴
- else tz.process(select); //입력값와 함계 TimeZone클래스에 입력값와 함께 들어감.
- }
- system("cls");
- cout<<"ByeBye"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement