1 #include <iostream> 2 #include <cstdio> 3 4 using namespace std; 5 6 class mytime 7 { 8 private: 9 int hour; 10 int minute; 11 int second; 12 public: 13 void settime(){cin>>hour>>minute>>second;return;} 14 void print_12(); 15 void print_24(); 16 }; 17 18 void mytime::print_12() 19 { 20 if(hour<12) 21 { 22 printf("%02d:%02d:%02d amn",hour,minute,second); 23 } 24 else 25 { 26 printf("%02d:%02d:%02d pmn",hour-12,minute,second); 27 } 28 return; 29 } 30 31 void mytime::print_24() 32 { 33 printf("%02d:%02d:%02dn",hour,minute,second); 34 return; 35 } 36 37 int main() 38 { 39 mytime one; 40 one.settime(); 41 one.print_12(); 42 one.print_24(); 43 return 0; 44 }
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/600005.html