跪求以下两个题目的编程,感激中......
1、编程,从键盘读入两个数,然后分别计算这两个数的平均值和这两个数的和,然后输出。
2、有一个4×5的矩阵,编写程序找出值最大的那个元素,输出其值以及所在的行号和列号。
参考答案:我用的是C语言:(已经可以正确运行)
1.
#include "stdio.h"
#include "conio.h"
main()
{
float a,b;
scanf("%f%f",&a,&b);
printf("average=%f\nsum=%f\n",(a+b)/2,a+b);
getch();
}
2.
#include "stdio.h"
#include "conio.h"
main()
{
int a[4][5],i,j,temp,b,c;
printf("please input 20 numbers.\n");
for(i=0;i<4;i++)
{
for(j=0;j<5;j++)
scanf("%d",&a[i][j]);
}
temp=a[0][0];
for(i=0;i<4;i++)
{
for(j=0;j<5;j++)
{
if(temp<a[i][j])
{
temp=a[i][j];
b=i;
c=j;
}
}
}
printf("the biggest is: %d\nrow:%d list:%d",temp,b+1,c+1);
getch();
}