int gcd (int m, int n)
{
/ / 인수에 0이 있으면 0을 반환
if ((0 == m) | | (0 == n))
return 0;
/ / 유클리드 방법
while (m! = n)
{
if (m> n) m = m - n;
else n = n - m;
}
return m;
} / / gcd
#include <stdio.h> #include <time.h> int main(){ time_t now = time(NULL); struct tm *pnow = localtime(&now); char buf[128]=""; sprintf(buf,"%d:%d:%d",pnow->tm_hour,pnow->tm_min,pnow->tm_sec); printf(buf);
getchar(); return 0; }
#include <stdio.h> #include <time.h> int main() { time_t now = time(NULL); struct tm *pnow = localtime(&now); char week[][3] = {"日","月","火","水","木","金","土"}; printf("今日は%2d年%2d月%2d日(%s)\n", pnow->tm_year+1900,
pnow->tm_mon + 1, pnow->tm_mday, week[pnow->tm_wday]); return 0; }