某年某月的天數
問題描述
輸入年和月,判斷該月有幾天?
輸入
輸入年和月,格式為年\月.
輸出量
輸出該月的天數.
樣本輸入
2009\1
樣本輸出
31
注意char c。有一個\要輸入
#include <stdio.h>
int main()
{
int year,month;
int isLeap=0;
int days;
char c;
scanf("%d",&year);
scanf("%c",&c);
scanf("%d",&month);
if((year%40&&year%100!=0)||(year%4000))
isLeap=1;
if(month1||month
days=31;
if(month4||month6||month9||month11)
days=30;
if(isLeap1&&month2)
days=29;
if(isLeap0&&month==2)
days=28;
printf("%d",days);
return 0;
}
相關推薦
js 輸出某年某月某日的天數/判斷閏年
con var ava return days for arr i++ mon console.log(getDays(2017,12,12)); function getDays(year,month,day){ var arr =
輸出某年某月某日的天數
|| 時間 數組 nth get 某月 代碼 turn false (1)第一步,先判斷是否是閏年; function isRN(year){ if(year%4===0 && year%100 !==0 || year%400 ===
某年某月的天數
問題描述 輸入年和月,判斷該月有幾天? 輸入 輸入年和月,格式為年\月. 輸出量 輸出該月的天數. 樣本輸入 2009\1 樣本輸出 31 注意char c。有一個\要輸入 #include <stdio.h> int main() { int year,month; i
1160-C語言實驗——某年某月的天數-JAVA
C語言實驗——某年某月的天數 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 輸入年和月,判斷該月有幾天? Inp
[1160]C語言實驗——某年某月的天數
題目描述 輸入年和月,判斷該月有幾天? 輸入 輸入年和月,格式為年\月。 輸出 輸出該月的天數。 示例輸入 2009\1 示例輸出 31 #include <stdio.h> void main() { int a,c; char b;
SDUT 1160 某年某月的天數
Problem Description 輸入年和月,判斷該月有幾天? Input 輸入年和月,格式為年\月。 Output 輸出該月的天數。 Example Input 2009\1 Exa
JAVA 題目:輸入某年某月某日,判斷這一天是這一年的第幾天?
再看 應該 boolean post pos tin als ini ror 1 package Training; 2 3 //import java.util.Calendar; 4 import java.util.Scanner; 5 /** 6
js判斷某年某月有多少天
.get var RM get new nth 獲取 某月 生成 function getCountDays(ym) { var curDate = new Date(ym); /* 獲取當前月份 */ var curMonth =
練習四:日期計算(輸入某年某月某日計算出這一天是該年第幾天的方法)
nbsp style 內置 練習 day pan and error == 實現輸入某年某月某日計算出這一天是該年第幾天的方法方法一:笨辦法 1 list_day = [0,31,28,31,30,31,30,31,31,30,31,30,31] 2 year
JAVA-查詢某年某月一個月的資料,以日曆的形式展示。
市場上有些這樣的應用,會展示某年某月一個月的資料,比如女神們經常用的“大姨媽”APP,一些遊戲的使用者簽到資訊,等等 那我們在寫後臺介面的時候,就需要返回這一個月的資料,今天我就分享一下筆者經常在工作中使用的方法。 資料庫DB中存了許多使用者的應用資料,每條資料有一個日期欄位,可以是I
輸入某年某月某日,判斷這一天是這一年的第幾天?(使用python語言)
1. import datetime 2. def dayofyear(): 3. year = input("請輸入年份:") 4. month = input("請輸入月份:") 5. day = input("請輸入天:") 6. date1 = dat
報表統計——java實現查詢某年某月每天資料,沒資料補0
一般圖表繪製例如echarts等,返回資料格式都大同小異。重點是利用sql或者java實現資料格式的轉型,接下來是關鍵部分: 1.前提1:提供的工具方法——獲取某月有多少天 //通過年份和月份確定該月的最後一天 public static int getMaxDay(int year,in
Java獲取某年某月的第一天和最後一天
public static String getLastDayOfMonth(int year, int month) { Calendar cal = Calendar.getInstance(); cal.set
C語言經典演算法 輸入某年某月某日 判斷這一天是這一年的第幾天
題目:輸入某年某月某日,判斷這一天是這一年的第幾天?1.程式分析:以3月5日為例,應該先把前兩個月的加起來,然後再加上5天即本年的第幾天,特殊 情況,閏年且輸入月份大於3時需考慮多加一天。2.程式原始碼:main(){int day,month,year,sum,le
C語言例項3——輸入某年某月某日,判斷這一天是這一年的第幾天?
題目:輸入某年某月某日,判斷這一天是這一年的第幾天? /* 程式分析:以3月5日為例,應該先把前兩個月的加起來, 然後再加上5天即本年的第幾天,特殊情況,閏年且輸入 月份大於3時需
python中輸入某年某月某日,判斷這一天是這一年的第幾天?
個數 light ear 數組 這一 day 年份 年月日 第幾天 輸入某年某月某日,判斷這一天是這一年的第幾天?程序分析 特殊情況,閏年時需考慮二月多加一天:直接上代碼 #定義一個函數,判斷是否為閏年 def leapyear(y): return (y % 4
第四題:輸入某年某月某日,判斷這一天是這一年的第幾天?
#輸入某年某月某日,判斷這一天是這一年的第幾天? '''思路:首先年月日是分著輸入還是一塊輸入,想到如果一塊輸入可能還需要分割分別找到年月日 所以還是分著輸入比較好;接著考慮計算天數其實就是往常月份的天數和加上本月天數(如:7月5號就是前6個月天數之和加上5) 那麼接下來的
題目:輸入某年某月某日,計算這個是該年的第幾天
function getDays() { // 定義總天數 var allDays = 0; // 定義2月份的天數 var feb = 28; // 獲取年份
NYOJ【75】日期計算【某年某月某日是第幾天】
日期計算 時間限制:3000 ms | 記憶體限制:65535 KB 難度:1 描述如題,輸入一個日期,格式如:2010 10 24 ,判斷這一天是這一年中的第幾天。 輸入第一行輸入一個數N(0<N<=100),表示有N組測試資料。後面的N行輸
C#判斷某年某月共有多少個週末,分別是哪幾天
注:本文中的週末指的是週六和週日雙休 本程式碼用的是基姆拉爾森公式來判斷某年某月某天是否為週末,關於這個公式,百度百科上有詳細介紹,這裡再贅述一下: 基姆拉爾森計算公式:W= (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod