#include <stdio.h>
int RY(int Y){
if ((Y%4==0)&&(Y%100!=0)||(Y%400==0)) return 1
else return 0
}
int DYM(int Y, int M){
const short MonthDay[]={0,31,28,31,30,31,30,31,31,30,31,30,31}
if (M==2) return (MonthDay[2]+RY(Y))
else return MonthDay[M]
}
int main()
{
int year, month
printf("input year month 2016 2:\n")
scanf("%d %d",&year,&month)
if (RY(year)==1) printf("leap year\n")else printf("No leap\n")
printf("%d-%02d: %d days\n",year, month, DYM(year,month))
return 0
}
---
函数 int RY(int Y); 输入年,闰年返回1,非 闰年返回 0。
函数 int DYM(int Y, int M)输入年月,返回该月天数。
(程序未考虑对输入数据的合理性作检查。)
#include<stdio.h>#define m 10
#define n 7
void mangeList( int *la,int*lb,int *lc){
int i=0
int j=0
int k=0
while(i!=m||j!=n){
if(i==m){
lc[k++]=lb[j++]
continue
}
if(j==n){
lc[k++]=la[i++]
continue
}
if(la[i]>lb[j]){
lc[k++]=lb[j++]
}
else{
lc[k++]=la[i++]
}
}
}
int main(){
int la[m]={1,3,5,8,9,15,23,35,36,38}
int lb[n]={2,4,6,7,10,11,27}
int lc[m+n]={0}
int i
mangeList(la,lb,lc)
for(i=0i<m+ni++)
{
printf("%d\n",lc[i])
}
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)