반응형
#include<stdio.h>
#include<stdlib.h>
main()
{
char x[10]="LOVE";
printf("x=%s\n",x);
printf("x=%d\n",x);
printf("x[1]=%c\n",x[1]);
printf("x[1]=%d\n",&x[1]);
system("pause");
}
날짜 요일구하는 프로그램
#include<stdio.h>
#include<stdlib.h>
main()
{
int i,y,m,d,tot=0,x,w;
int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
char week[7][3]={"일","월","화","수","목","금","토"};
printf("태어난 년도 입력\n");
scanf("%d",&y);
printf("태어난 월 입력\n");
scanf("%d",&m);
printf("태어난 일 입력\n");
scanf("%d",&d);
x=(y-1)/4+(y-1)/400 - (y-1)/100;
tot=(y-1)*365+x;
if (y%400==0 || y%4==0 && y%100!=0)
month[1]=29;
for(i=0;i<m-1;i++)
tot+=month[i];
tot+=d;
w= tot%7;
printf("%d년 %d월 %d일은 %s요일 입니다.\n",y,m,d,week[w]);
system("pause");
}
반응형
'다른공부 > C언어' 카테고리의 다른 글
20160517 c언어 교양 (0) | 2016.05.17 |
---|---|
c언어 교양 20160510 (0) | 2016.05.10 |
20160428 c언어 교양 (0) | 2016.04.28 |
20160426 c언어 교양 (0) | 2016.04.26 |
c언어 교양 20160414 (0) | 2016.04.14 |