cとc++の時間

1467 ワード

//clock()                ;
//   ctime         —CLOCKS_PER_SEC ,                  ;
//       CLOCKS_PER_SEC      ;     CLOCKS_PER_SEC               ;
//ctime clock_t  clock()       ,           clock_t;
//      clock()/CLOCKS_PER_SEC              ;
//    clock                               ;
 
//    
#include <iostream>
#include <ctime>
int main()
{
 using namespace std;
 float  secs;
 cin >>secs;
 clock_t delay =secs* CLOCKS_PER_SEC;
 clock_t start =clock();
 while (clock()-start<delay)
 ;
 cout <<"done!
" ; system("pause"); } // #include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { long i = 10000000L; clock_t start, finish; double duration; /* */ printf( "Time to do %ld empty loops is ", i) ; start = clock(); while( i-- ); finish = clock(); duration = (double)(finish - start) / CLOCKS_PER_SEC; printf( "%f seconds
", duration ); system("pause"); } // ctime // : #include <stdio.h> #include <time.h> int main(void) { time_t t; t=time(&t); printf("Today's date and time: %s
", ctime(&t)); // system("pause"); return 0; } // 1970 1 1 ; #include <stdio.h> #include <time.h> int main() { time_t t; time(&t); printf("%d",t); system("pause"); }