# C/C++之练习题4-5

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
/*1.大小月
*2.闰年否？
*/

int year,month,day,leap=2,sum=0,number = 30;
printf("请输入年月日\n");
printf("公元\n");
scanf("%d",&year );
printf("年\n");
scanf("%d",&month,&day);
printf("月\n");
scanf("%d",&day);
printf("日\n");
if(year%400==0 ||((year%4==0)&&(year%100)!=0)){
leap = 1;
}

switch(month)
{
case 1:
sum = day;
break;
case 2:
sum = day+31;
break;
case 3:
sum =(month-1)*30-leap+day+1;
break;
case 4:
sum =(month-1)*30-leap+day+2;
break;
case 5:
sum =(month-1)*30-leap+day+2;
break;
case 6:
sum =(month-1)*30-leap+day+3;
break;
case 7:
sum =(month-1)*30-leap+day+3;
break;
case 8:
sum =(month-1)*30-leap+day+4;
break;
case 9:
sum =(month-1)*30-leap+day+5;
break;
case 10:
sum =(month-1)*30-leap+day+5;
break;
case 11:
sum =(month-1)*30-leap+day+6;
break;
case 12:
sum =(month-1)*30-leap+day+6;
break;
}

printf("为公元%d年%d月%d日的第%d天\n",year,month,day,sum);
system("pause");
return 0;

}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
/*1.大小月
*2.闰年否？
*/

int year,month,day,leap=2,sum=0,number = 30;
printf("请输入年月日\n");
printf("公元\n");
scanf("%d",&year );
printf("年\n");
scanf("%d",&month,&day);
printf("月\n");
scanf("%d",&day);
printf("日\n");
if(year%400==0 ||((year%4==0)&&(year%100)!=0)){
leap = 1;
}

switch(month)
{
case 1:
sum = day;
break;
case 2:
sum = day+31;
break;
case 3:
sum =(month-1)*30-leap+day+1;
break;
case 4:

case 5:
sum =(month-1)*30-leap+day+2;
break;
case 6:

case 7:
sum =(month-1)*30-leap+day+3;
break;
case 8:
sum =(month-1)*30-leap+day+4;
break;
case 9:

case 10:
sum =(month-1)*30-leap+day+5;
break;
case 11:

case 12:
sum =(month-1)*30-leap+day+6;
break;
}

printf("为公元%d年%d月%d日的第%d天\n",year,month,day,sum);
system("pause");
return 0;

}

【程序5】

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
/**
1.主要是比较如何比较最好~
*/
int x,y,z;
printf("请输入是三个数\n");
//      scanf("%d,%d,%d",&x,&y,&z);

/*开始比较大小
*/
int a[3],i;
for(i= 0;i<3;i++){
scanf("%d",&x);
a[i]= x;
}
int tep;
for(i= 1;i<3;i++){
for（j=i;j<3;j++）{
if( a[i-1]>a[j]){
tep = a[i-1];
a[i-1]=a[j];
a[j] = tep;
}
}

}
for(i= 0;i<3;i++){
printf("%d\t",a[i]);
}

system("pause");
return 0;

}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int funtion(int *a[]){

int *tep,i,j;
for(i=1;i<3;i++){
for(j = i;j<3;j++){
if(* a[i-1]>*a[j]){
*tep = *a[i-1];
* a[i-1]=*a[j];
* a[j] =* tep;
}
}
}

return **a;
}

int main(){
/**
1.主要是比较如何比较最好~
*/
int x,y,z;
printf("请输入是三个数\n");
//      scanf("%d,%d,%d",&x,&y,&z);

/*开始比较大小
*/
int a[3],i;
int *ptr[3],*t[3];
for(i= 0;i<3;i++){
scanf("%d",&x);
a[i]= x;
ptr[i]= &a[i];
}

funtion(ptr);

for(i= 0;i<3;i++){
printf("%d\t",*ptr[i]);
}

printf("\n");
system("pause");
return 0;

}


#### 《C程序设计语言》练习 4-5

2018-01-04 17:41:55

#### The C Programming Language 练习题4-5

2017-10-19 19:19:28

#### 《Python编程》第四章部分课后练习题

2018-03-15 16:50:50

#### 系列练习题（C/C++）

2017-09-05 08:43:41

#### c/c++ 基本习题练习

2018-01-15 02:54:34

#### 1000道C语言和C++语言的练习题笔试题及答案 #0000-0050

2015-03-18 07:49:18

#### 一个简单的C、C++练习题

2010-08-25 22:04:00

#### C语言入门第九篇，循环语句练习题

2017-09-29 16:49:05

#### C++练习题C++练习题C++练习题

2009年05月30日 32KB 下载

#### c++基础上机练习题

2015年08月11日 19KB 下载