循环
#include <stdio.h>
void main(){
//用户输入几 就会输出星期几
/* 第一种方法
int day;
printf("请输入星期几\n");
scanf("%d",&day);
switch(day){
case 1:
printf("星期一\n");
break;
case 2:
printf("星期二\n");
break;
case 3:
printf("星期三\n");
break;
case 4:
printf("星期四\n");
break;
case 5:
printf("星期五\n");
break;
case 6:
printf("星期六\n");
break;
case 7:
printf("星期天\n");
break;
default:
printf("输入有误,请重新输入");
break;
}
*/
//第二种方法
/*int day;
printf("请输入星期几\n");
scanf("%d",&day);
if(day==1){
printf("星期一");
}else if(day==2) {
printf("星期二\n",day);
}else if(day==3) {
printf("星期三\n",day);
}else if(day==4) {
printf("星期四\n",day);
}else if(day==5) {
printf("星期五\n",day);
}else if(day==6) {
printf("星期六\n",day);
}else {
printf("星期日\n",day);
}
*/
//根据分数分出等级 第一种方法
/*int score;
printf("请输入你的成绩\n");
scanf("%d",&score);
if(score>=90&&score<=100) {
printf("成绩为A类\n",score);
}else if(score<90&&score>=80){
printf("成绩为B类\n",score);
}else if(score<80&&score>=70){
printf("成绩为C类\n",score);
}else if(score<70&&score>=60){
printf("成绩为D类\n",score);
}else{
printf("成绩为E类\n",score);
}*/
//第二种方法
/*int score,coreco;
printf("请输入你的成绩\n");
scanf("%d",&coreco);
score= coreco/10;
switch(score){
case 10:
case 9:
printf("成绩为A类\n");
break;
case 8:
printf("成绩为B类\n");
break;
case 7:
printf("成绩为C类\n");
break;
case 6:
printf("成绩为D类\n") ;
break;
default:
printf("成绩为E类\n") ;
break;
}*/
//根据用户输入的年份,月份,日期计算该日期是一年中的第几天?
int Total,Day,Month,Year,time,m;
printf("请输入:年:月:日:\n");
scanf("%d%d%d",&Year,&Month,&Day);
switch((Year%4==0)&&(Year%100!=0)||(Year%400==0)){
case 1:
{
switch(Month){
case 1:time=Day;break;
case 2:time=31+Day;break;
case 3:time=31+29+Day;break;
case 4:time =31*2+29+Day;break;
case 5:time=31*2+29+30+Day;break;
case 6:time=31*3+29+30+Day;break;
case 7:time =31*3+29+30*2+Day;break;
case 8:time =31*4+29+30*2+Day;break;
case 9:time =31*5+29+30*2+Day;break;
case 10:time=31*5+29+30*3+Day;break;
case 11:time =31*6+29+30*3+Day;break;
case 12:time =31*6+29+30*4+Day;break;
}
}break;
default:{
switch(Month){
case 1:time=Day;break;
case 2:time=31+Day;break;
case 3:time=31+28+Day;break;
case 4:time =31*2+28+Day;break;
case 5:time= 31*2+28+30+Day;break;
case 6:time=31*3+28+30+Day;break;
case 7:time =31*3+28+30*2+Day;break;
case 8:time =31*4+28+30*2+Day;break;
case 9:time =31*5+28+30*2+Day;break;
case 10:time=31*5+28+30*3+Day;break;
case 11:time =31*6+28+30*3+Day;break;
case 12:time =31*6+28+30*4+Day;break;
}
}
}
printf("%d:%d:%d 是 %d Day\n",Year,Month,Day,time);
}