试题吧 关注:1,050贴子:516
  • 8回复贴,共1
冒泡法


1楼2020-04-30 19:47回复
    我丢


    2楼2020-05-03 16:26
    回复
      提。。。


      3楼2020-05-03 16:27
      回复
        中国有句俗话叫“三天打鱼两天晒网”,某人从1990年1月1日期开始“三天打鱼两天晒网”,即工作三天,然后再休息两天。问这个人再以后的某一天中是在工作还是在休息。从键盘任意输入一天,编程判断他是在工作还是在休息,如果是在工作,则输出:He is working,如果是在休息,则输出:He is having a rest, 如果输入的年份小于1990或者输入的月份和日期不合法,则输出: Invalid input.


        5楼2020-05-03 19:47
        回复
          什么情况?


          6楼2020-05-03 19:49
          回复
            中国有句俗话叫“三天打鱼两天晒网”,某人从1990年1月1日期开始“三天打鱼两天晒网”,即工作三天,然后再休息两天。问这个人再以后的某一天中是在工作还是在休息。从键盘任意输入一天,编程判断他是在工作还是在休息,如果是在工作,则输出:He is working,如果是在休息,则输出:He is having a rest, 如果输入的年份小于1990或者输入的月份和日期不合法,则输出: Invalid input.


            7楼2020-05-03 19:51
            回复
              #include <stdio.h>
              int main(void)
              {
              int year,month,date,flag=0,year1,month1,date1,flag1=0;
              int sum,sum1,temp;
              scanf("%d.%d.%d",&year,&month,&date);
              if(1990 > year || month > 12 ||month < 1 || date < 1||date >31)
              {
              printf("invalid input\n" );
              return -1;
              }
              switch(month){
              case 4:
              case 6:
              case 9:
              case 11:
              if(date>30)
              {
              printf("invalid input\n" );
              return -1;
              }
              case 2:
              if(year1%4==0&&year%10!=0||year%100==0)
              {
              if(date>29)
              {
              printf("invalid input\n" );
              return -1;
              }
              }
              else
              {
              if(date>28)
              {
              printf("invalid input\n" );
              return -1;
              }
              }
              default:
              break;
              }
              for(year1=1990;year1<=year;year1++)
              {
              if(year1%4==0&&year%10!=0||year%100==0)
              flag+=1;
              else flag1+=1;
              }
              sum=366*flag+365*flag1;
              sum1=0;
              for(int a=12;a>=month;a--)
              {
              switch(a)
              {
              case 1: case 3: case 5: case 7: case 8: case 10: case 12 : temp=31;break;
              case 4: case 6: case 9: case 11: temp=30;break;
              case 2:
              {
              if(year1%4==0&&year%10!=0||year%100==0)
              temp=29;
              else temp=28;
              }
              break;
              default: temp=0;
              }
              sum1+=temp;
              }
              sum=sum-sum1+date;
              if(sum%5==0||sum%5==4)
              {
              printf("He is having a rest!\n");
              }
              else printf("He is working!\n");
              }


              8楼2020-05-03 20:30
              回复
                #include <stdio.h>
                int main(void)
                {
                int year,month,date,flag=0,year1,month1,date1,flag1=0;
                int sum,sum1,temp;
                scanf("%d.%d.%d",&year,&month,&date);
                if(1990 > year || month > 12 ||month < 1 || date < 1||date >31)
                {
                printf("invalid input\n" );
                return -1;
                }
                switch(month){
                case 4:
                case 6:
                case 9:
                case 11:
                if(date>30)
                {
                printf("invalid input\n" );
                return -1;
                }
                case 2:
                if(year1%4==0&&year%10!=0||year%100==0)
                {
                if(date>29)
                {
                printf("invalid input\n" );
                return -1;
                }
                }
                else
                {
                if(date>28)
                {
                printf("invalid input\n" );
                return -1;
                }
                }
                default:
                break;
                }
                for(year1=1990;year1<=year;year1++)
                {
                if(year1%4==0&&year1%10!=0||year1%100==0)
                flag+=1;
                else flag1+=1;
                }
                sum=366*flag+365*flag1;
                sum1=0;
                for(int a=12;a>=month;a--)
                {
                switch(a)
                {
                case 1: case 3: case 5: case 7: case 8: case 10: case 12 : temp=31;break;
                case 4: case 6: case 9: case 11: temp=30;break;
                case 2:
                {
                if(year1%4==0&&year%10!=0||year%100==0)
                temp=29;
                else temp=28;
                }
                break;
                default: temp=0;
                }
                sum1+=temp;
                }
                sum=sum-sum1+date;
                if(sum%5==0||sum%5==4)
                {
                printf("He is having a rest!\n");
                }
                else printf("He is working!\n");
                }


                9楼2020-05-03 20:37
                回复
                  #include <stdio.h>
                  int main(void)
                  {
                  int year,month,date,flag=0,year1,month1,date1,flag1=0;
                  int sum,sum1,temp;
                  scanf("%d.%d.%d",&year,&month,&date);
                  if(1990 > year || month > 12 ||month < 1 || date < 1||date >31)
                  {
                  printf("invalid input\n" );
                  return -1;
                  }
                  switch(month){
                  case 4:
                  case 6:
                  case 9:
                  case 11:
                  if(date>30)
                  {
                  printf("invalid input\n" );
                  return -1;
                  }
                  case 2:
                  if(year1%4==0&&year%10!=0||year%100==0)
                  {
                  if(date>29)
                  {
                  printf("invalid input\n" );
                  return -1;
                  }
                  }
                  else
                  {
                  if(date>28)
                  {
                  printf("invalid input\n" );
                  return -1;
                  }
                  }
                  default:
                  break;
                  }
                  for(year1=1990;year1<=year;year1++)
                  {
                  if(year1%4==0&&year1%10!=0||year1%100==0)
                  flag+=1;
                  else flag1+=1;
                  }
                  sum=366*flag+365*flag1;
                  sum1=0;
                  for(int a=12;a>=month;a--)
                  {
                  switch(a)
                  {
                  case 1: case 3: case 5: case 7: case 8: case 10: case 12 : temp=31;break;
                  case 4: case 6: case 9: case 11: temp=30;break;
                  case 2:
                  {
                  if(year1%4==0&&year1%10!=0||year1%100==0)
                  temp=29;
                  else temp=28;
                  }
                  break;
                  default: temp=0;
                  }
                  sum1+=temp;
                  }
                  sum=sum-sum1+date;
                  if(sum%5==0||sum%5==4)
                  {
                  printf("He is having a rest!\n");
                  }
                  else printf("He is working!\n");
                  }


                  10楼2020-05-03 20:38
                  回复