第四十六题
#include “stdio.h”
void main()
{
int arr[3][3];
int i,j,max,min;
int max_i,max_j;
int min_i,min_j;
printf(“please input the arr:\n”);
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&arr[i][j]);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf("%5d",arr[i][j]);
printf("\n");
}
max=arr[0][0];
min=arr[0][0];
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
if(arr[i][j]>max)
{
max=arr[i][j];
max_i=i;
max_j=j;
}
if(arr[i][j]<min)
{
min=arr[i][j];
min_i=i;
min_j=j;
}
}
printf(“the result is :\n”);
printf(“the max element is %d, index is [%d][%d]\n\n”,max,max_i,max_j);
printf(“the min element is %d, index is [%d][%d]\n\n”,min,min_i,min_j);
}
第四十七题
#include<stdio.h>
main()
{
int year,mouth,day,days=0;
int w,m,d,y;
printf(“请输入年,月,日\n”);
scanf("%d%d%d",&y,&m,&d);
mouth=m;
year=y;
day=d;
switch(mouth)
{
case 1:days=0;break;
case 2:days=31;break;
case 3:days=59;break;
case 4:days=90;break;
case 5:days=120;break;
case 6:days=151;break;
case 7:days=181;break;
case 8:days=212;break;
case 9:days=243;break;
case 10:days=273;break;
case 11:days=304;break;
case 12:days=334;break;
}
days+=day;
if(mouth>2&&year%40&&year%100!=0||year%4000)
days++;
printf("%d年%d月%d日第%d天",year,mouth,day,days);
}
第四十八题
#include<stdio.h>
main()
{
int i,j,k,count=0;
for(i=1;i<5;i++)
{
for(j=0;j<5;j++)
{
for(k=0;k<5;k++)
{
if(i!=j&&j!=k&&i!=k)
{
count++;
printf("%d%d%d “,i,j,k);
if(count%5==0)
printf(”\n");
}
}
}
}
printf("\n一共有%d种方法",count);
}
第四十九题
#include"stdio.h"
void main()
{
int a,b,t,r,n;
printf(“please input the a and b:\n”);
scanf("%d%d",&a,&b);
if(a<b)
{
t=b;
b=a;
a=t;
}
r=a%b;
n=a*b;
while(r!=0)
{
a=b;
b=r;
r=a%b;
}
printf(“这两个数的最大公约数为%d,最小公倍数为%d\n”,b,n/b);
}