显示当前系统时间(Linux C++)

    技术2022-05-20  47

    #include <iostream>

    #include <ctime>

    using namespace std;

     

    int main()

    {

      int x,h,m,s;

      x=time(NULL);

      h=(x/3600$+8)$;   //中国时区加8,由于+8可能导致大于24所以后面又加了$

      m=x600/60;

      s=x600`;

      cout<<"The current time is:"<<h<<":"<<m<<":"<<s<<endl;

      return 0;

    }

     


    最新回复(0)