Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  counter
Language: C/C++
Code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
int main()
{
     SYSTEMTIME t;
     int n1=2011,n2=6,n3=28,n4=18,n5=0,n6=0,d1,d2,d3,d4,d5,d6,x;
     
     While(1)
     {
          GetSystemTime(&t);
          d6=t.wSecond;
          d5=t.wMinute;
          if(t.wHour<n4)
          {
               t.wDay--;
               t.wHour+=24;
          }
          d4=t.wHour-n4;
          if(t.wDay<n3)
          {
               t.wMonth--;
               switch(t.wMonth)
               {
                    case2:
                    if(t.wYear%4)x=28;
                    else x=29; break;
                    case 4:x=30; break;
                    case 6:x=30; break;
                    case 9:x=30;break;
                    case 11:x=30;break;
                    default: x=31;
               }
               t.wDay+=x;
          }
          d3=t.wDay-n3;
          if(t.wMonth<n2)
          {
               t.wYear--;
               t.wMonth+=12;
               
          }
          d2=t.wMonth-n2;
          d1=t.wYear-n1;
          printf("%d year %d month %d day %d hour %d minute %d second",d1,d2,d3,d4,d5,d6);
     }
     system("PAUSE");
     return 0;
}
          
Comments: