날짜계산프로그래밍.
솔길
질문 제목 : 뭐가 잘못됐는지 모르겠는데 일수가 다르게 나옵니다도움 좀 주세요질문 내용 : #include stdio.h
int month_1(int i)
{
int a=0;
if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12) {a=31;}
else if(i==2)
{a=28; if((i%4==0&& i%100==0) || (i%400==0)) {a=29;}}
else(i==4 || i==6 || i==9 || i==11); {a=30;}
return a;
}
int year_f(int f[], int s[])
{
int year=0;
if((f[1]==s[1]&&f[2]s[2]) || (f[2]==s[2]&&f[1]s[1]) || (f[1]s[1]&&f[2]s[2])) {s[0]=s[0]-1; year=s[0]-f[0];}
else((f[1]s[1]&&f[2]==s[2]) || (f[1]s[1]&&f[2]s[2]) || (f[1]s[1]&&f[2]s[2])); {year=s[0]-f[0];}
return year;
}
int month(int f[], int s[])
{
if((f[1]==s[1]&&f[2]s[2]) || (f[2]==s[2]&&f[1]s[1]) || (f[1]s[1]&&f[2]s[2])) {s[1]=s[1]+12; printf(%달 차이 납니다\n,s[1]-f[1]);}
else((f[1]s[1]&&f[2]==s[2]) || (f[1]s[1]&&f[2]s[2]) || (f[1]s[1]&&f[2]s[2])); {return s[1]-f[1];}
}
int day(int f[], int s[])
{
int i=0;
if(s[1]f[1]&&s[2]f[2] || s[1]f[1]&&s[2]==f[2] || f[1]==s[1]&&s[2]f[2]) { return s[2]-f[2];}
else(f[1]==s[1]&&f[2]s[2] || f[1]s[1]&&f[2]s[2] || f[1]s[1]&&f[2]s[2]); {i=month_1(s[1]); s[2]=s[2]+i; printf(%일 차이 납니다\n,s[2]-f[2]); return s[2]-f[2];}
}
int allday(int f[], int s[])
{
int a,i,j,day1=0,k,b;
a=year_f(f,s);
b=allday2(f,s)+day(f,s);
for(i=1; i=a; i++)
{
for(j=1; j13; j++)
{k=month_1(j); day1=day1+k;}
}
printf(%d는 총일수 입니다\n,day1+b);
}
int allday2(int f[], int s[])
{
int i,k=0,day1=0,a=0;
for(i=f[1]; is[1]; i++)
{k=month_1(i); day1=day1+k;}
return day1;
}
main()
{
int f[3];
int s[3];
int i=0,year=0,dayy=0,month1=0;
printf(생년 월 일 : );
scanf(%d %d %d,&f[0],&f[1],&f[2]);
printf(날짜 입력 : );
scanf(%d %d %d,&s[0],&s[1],&s[2]);
year=year_f(f,s);
printf(%d년 차이가 납니다\n,year);
month1=month(f,s);
printf(%d달 차이가 납니다\n,month1);
dayy=day(f,s);
printf(%d일 차이가 납니다\n,dayy);
allday(f,s);
allday2(f,s);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2694854 | 절대값을 구할때 (2) | 그녀는귀여웠다 | 2025-05-15 |
2694827 | 이제 어떻게 공부해야할지 모르겠네요 | 새얀 | 2025-05-14 |
2694778 | 순열 계산요. | 맛조이 | 2025-05-14 |
2694754 | ShowWindow 함수를 이용하려 하는데 질문있습니다. (2) | 파도 | 2025-05-14 |
2694731 | 리눅스 커널의 시작점 질문 | 미르 | 2025-05-13 |
2694702 | 이거 뭐가문제인가요 코드수정좀 (3) | 맑은 | 2025-05-13 |
2694675 | C언어 후위표기를 중위표기로 | 앨런 | 2025-05-13 |
2694646 | 안녕하세요 파일 합치기 함수! (1) | 연블루 | 2025-05-13 |
2694618 | 잘몰라서 설명부탁드립니다. scanf 관련 (3) | 파라 | 2025-05-12 |
2694590 | 이 코드가 뭐하는 코드일까요? #2 | 빵순 | 2025-05-12 |
2694559 | 동적할당으로 배열(2차원열)을 만드는데 있어 그걸 함수화시키는데... (1) | 늘솔길 | 2025-05-12 |
2694532 | 네트워크에 관하여... (4) | 황소자리 | 2025-05-12 |
2694503 | 프로그램 연산 후 바로 종료되는 현상 (6) | Judicious | 2025-05-11 |
2694450 | while문질문입니다. (1) | 허리품 | 2025-05-11 |
2694420 | C언어 질문할게요(유니코드,자료형,버퍼,캐스트연산자) | 은새 | 2025-05-11 |
2694370 | 내일까진데 함수호출 제발 도와주세요!!!!!!!!!11 | 들찬 | 2025-05-10 |
2694339 | putchar()의 괄호 안에 int c=10;로 전에 선언된 c를 넣으면 안되는 이유에서 제가 생각한 것이 그 이유가 되는지 확인하고 싶습니다. (3) | 미르 | 2025-05-10 |
2694316 | 이 코드 어디가 잘못되었는지 고수분들 ㅠㅠ (2) | 나빛 | 2025-05-10 |
2694285 | 언어 공부하는 과정 좀 추천해주세요! (1) | 아빠몬 | 2025-05-09 |
2694258 | 카운터.. 질문입니다. (4) | 하늘빛눈망울 | 2025-05-09 |