计算该日在本年中是第几天
时间: 1ms 内存:128M
描述:
定义一个结构体变量(包括年、月、日)。计算该日在本年中是第几天,注意闰年问题。
输入:
年月日
输出:
当年第几天
示例输入:
2000 12 31
示例输出:
366
提示:
参考答案(内存最优[748]):
int N=100;
struct student
{char num[6];
char name[8];
int score[3];
}stu[100];
void print(struct student st)
{ int i,j;
printf("%s,%s",st.num,st.name);
for(j=0;j<3;j++)
printf(",%d",st.score[j]);
printf("\n");
}
main()
{int i,j ;
scanf ("%d",&N);
for(i=0;i<N;i++)
{
//printf("Input score of student %d:\n",i+1);
//printf("no.:");
scanf("%s",stu[i].num);
///printf("name:");
scanf("%s",stu[i].name);
for(j=0;j<3;j++)
{//printf("score%d:",j+1);
scanf("%d",&stu[i].score[j]);
}
print(stu[i]);
}
}
参考答案(时间最优[0]):
int N=100;
struct student
{char num[6];
char name[8];
int score[3];
}stu[100];
void print(struct student st)
{ int i,j;
printf("%s,%s",st.num,st.name);
for(j=0;j<3;j++)
printf(",%d",st.score[j]);
printf("\n");
}
main()
{int i,j ;
scanf ("%d",&N);
for(i=0;i<N;i++)
{
//printf("Input score of student %d:\n",i+1);
//printf("no.:");
scanf("%s",stu[i].num);
///printf("name:");
scanf("%s",stu[i].name);
for(j=0;j<3;j++)
{//printf("score%d:",j+1);
scanf("%d",&stu[i].score[j]);
}
print(stu[i]);
}
}
题目和答案均来自于互联网,仅供参考,如有问题请联系管理员修改或删除。