5. 년도와 월을 입력하여 달력을 출력하는프로그램
#include
{
int year, month, day;
int last[12]={31,28,31,30,31,30,31,31,30,31,30,31};
long total;
int year_1, i;
int totalday, adayofweek, weekday; printf("년도 월 일 :");
scanf_s("%d %d %d",&year, &month, &day,sizeof(year),sizeof(month),sizeof(day)); year_1 = year - 1;
totalday = year_1*365 + year_1/4 - year_1/100 + year_1/400;
if ( !(year%4) &&(year0) || !(year%400) )
last[1] = 29;
for (i=0;i
totalday += last[i];
totalday++;
adayofweek = totalday % 7;
printf("\n\n %4d.%4d \n\n", year,month);
printf(" SUN MON TUE WED THU FRI SAT");
printf("\n------------------------------\n");
for (i=0;i
printf(" ");
for (i=1;i<=last[month-1]; i++)
{
printf("%4d", i);
if ( !((i+adayofweek)%7) )
printf("\n");
}
printf("\n------------------------------\n");
if ((year%4 == 0) &&(year0 != 0) || (year%400 ==0 ))
{
if( month == 2 )
printf("마지막일은 29일 입니다.\n");
else
printf("마지막일은 %d일 입니다.\n",last[month-1]);
}
else
printf("마지막일은 %d일 입니다.\n",last[month-1]);
total = total_days(year, month, day); return 0;
} long total_days(int year, int month, int day)
{
int months[]={31,28,31,30,31,30,31,31,30,31,30,31};
int i;
long total;
total=(year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400;
if((year%4 == 0) &&(year0 != 0) || (year%400 ==0 ))
months[1]++; for(i=0; i
total = total+months[i];
total = total+day; return total;
}
6. 10명의 학생이름과 3개의 과목을 입력하여 합계순으로 출력하고 등수까지 출력하는프로그램 (구조체이용)
#include
#define MAX_STUDENT 10
struct student
{
char name[20];
int korean, english, math;
int total;
double average;
int rank;
};
int main(void)
{
struct student std[MAX_STUDENT], t;
int i, j;
double total_average = 0;
printf("%d 명의 학생 정보를 입력하세요.\n", MAX_STUDENT);
for(i=0; i < MAX_STUDENT; i++)
{
printf("이름: ");
scanf("%s",std[i].name);
printf("국어,영어,수학 점수: ");
scanf("%d %d %d",&std[i].korean, &std[i].english, &std[i].math);
std[i].total=std[i].korean+std[i].english+std[i].math;
std[i].average=std[i].total/3.0;
total_average+=std[i].average;
}
total_average/=MAX_STUDENT;
for(i=0; i < MAX_STUDENT; i++)
{
std[i].rank=1;
for(j=0; j < MAX_STUDENT; j++)
{
if (std[i].total < std[j].total) std[i].rank++;
}
}
for (i=0;i < MAX_STUDENT-1;i++)
{
for (j=1;j < MAX_STUDENT-i;j++)
{
if (std[j-1].total < std[j].total)
{
t=std[j-1];
std[j-1]=std[j];
std[j]=t;
}
}
}
printf("\n 이 름 국어 영어 수학 합계 평균 등수\n");
for(i=0; i < MAX_STUDENT; i++)
{
printf("%-10s %4d %4d %4d %4d %6.2f %3d\n",std[i].name,std[i].korean,std[i].english,std[i].math,std[i].total,std[i].average,std[i].rank);
}
printf("전체평균 : %6.2f\n", total_average);
return 0;
}
대충2개인데
2만원 보내드림
1개식해서 돈나눠서받기도가느함
아니면 1개 30퍼센트만하면 2만원의 15퍼센트 먼저이렇게보내서 최대한신뢰할수잇는쪽으로함







