zoukankan      html  css  js  c++  java
  • 计概期末前的小小总结

    1.日期问题

    基本上是必考的

    一定要注意闰年的处理!!

    别忘了判断【今年】是不是闰年

    题目 打鱼还是晒网  
    描述
    中国有句俗语叫“三天打鱼两天晒网”。某人从1990年1月1日起开始“三天打鱼两
    天晒网”,问这个人在以后的某一天中是“打鱼”还是“晒网”。
    注意要区分闰年和不是闰年的两种情况
    
    
    关于输入
    输入为三个整数
    按照年 月 日 输入为之后的某一天
    
    
    关于输出
    输出为单词
    如果今天渔夫打鱼就是
    fishing
    如果今天晒网就是
    sleeping
    
    
    例子输入
    1991 10 25
    例子输出
    fishing
     1 #include<iostream>
     2 using namespace std;
     3 bool isr(int year){
     4     if(year%4==0&&year%100!=0)
     5         return true;
     6     if(year%400==0) //世纪闰年 
     7         return true;
     8     return false; 
     9 }
    10 int main(){
    11     int year, month, day;
    12     cin>>year>>month>>day;
    13     int total = 0;
    14     int leap;
    15     for(int y = 1990; y < year; y++){ //先算年 
    16         leap = isr(y);
    17         total += 365+leap;
    18     }
    19     leap=isr(year);
    20     for(int m = 1; m < month; m++){
    21         switch(m){
    22             case 2: total+=28+leap; break;
    23             case 4:; case 6:; case 9:; case 11: total+=30; break;
    24             default: total+=31; break;
    25         }
    26     }
    27     total += day;
    28     if(total%5==4||total%5==0) cout<<"sleeping"<<endl;
    29     else cout<<"fishing"<<endl;
    30     return 0;
    31 } 

    备注:

  • 相关阅读:
    oracle在没
    一天中时针和分钟重合的次数
    oracle的隐藏的东东
    左右小移动
    JS全选的操作
    JS定时器
    在文件中查找字符串
    表单原件
    div和span互换
    div和span的区别
  • 原文地址:https://www.cnblogs.com/fangziyuan/p/12149694.html
Copyright © 2011-2022 走看看