MUstar

IoT C++ 09/05 - 초간단 세계시간출력 프로그램

Sep 5th, 2017
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<ctime>
  3. #include<string.h>
  4. #include<stdlib.h>
  5. #include<conio.h>
  6. using namespace std;
  7.  
  8. class TimeZone //타임설정및출력
  9. {
  10. public:
  11.     TimeZone() //기본시간 및 시스템시간
  12.     {
  13.         timenow = time(0);
  14.         tmp = timenow / 86400;
  15.         s = timenow%60;
  16.         m = (timenow/60)-(timenow/3600*60);
  17.         h = (timenow/3600)-(tmp*24);
  18.         bh = ((timenow+32400)/3600)-(tmp*24);
  19.     }
  20.     int timenow; int tmp;
  21.     int s; int m; int h;
  22.     int bm; int bh;
  23.     void process(int select)
  24.     {
  25.         char city[20]; //시티이름
  26.         switch(select) //입력값에 따라 시간을 더하고 문자열저장.
  27.         {
  28.             case 1: h+=9; strcpy(city,"서울/도쿄"); break;
  29.             case 2: h-=5; strcpy(city,"뉴욕"); break;
  30.             case 3: strcpy(city,"런던"); break;
  31.             case 4: h+=8; strcpy(city,"시드니"); break;
  32.             default: break;
  33.         }
  34.         output(city); //출력
  35.         return;
  36.     }
  37.     void output(char *city) //출력
  38.     {
  39.         system("cls");
  40.         if(h>=24) h-=24;
  41.         system("cls");
  42.         cout<<"컴퓨터시간 : "<<bh<<":"<<m<<":"<<s<<endl;
  43.         cout<<city<<"시간 : "<<h<<":"<<m<<":"<<s<<endl;
  44.         cout<<"계속하시려면 아무키나 누르세요."<<endl;
  45.         getch();    //아무값이나 입력받으면 나옴.
  46.     }
  47. };
  48.  
  49. int main(void)
  50. {
  51.     while(1)
  52.     {
  53.         TimeZone tz; //Class초기화
  54.         system("cls");
  55.         int select;
  56.         cout<<"초간단 세계시간출력 프로그램"<<endl;
  57.         cout<<"1)서울/도쿄 2)뉴욕 3)런던 4)시드니 5)[종료]"<<endl;
  58.         cout<<"Input : ";
  59.         cin>>select;    //값입력
  60.         if(select==5) break; //입력값이 5면 while나옴
  61.         else tz.process(select); //입력값와 함계 TimeZone클래스에 입력값와 함께 들어감.
  62.     }
  63.     system("cls");
  64.     cout<<"ByeBye"<<endl;
  65.     return 0;
  66. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×