第1个回答 推荐于2016-11-01
1/
#include <stdio.h>
int main()
{
int a[3][4] = {{1,2,3,4},{2,3,4,5},{7,4,3,2}};
int i, j, k, m, max = 0;
for(i = 0; i < 3; i++)
{
for(j = 0; j < 4; j++)
{
if(max < a[i][j])
{
max = a[i][j];
k = i;
m = j;
}
}
}
printf("%d %d %d\n", max, k + 1, m + 1);
}
2/
#include <stdio.h>
int main()
{
char p[1024];
int num = 0, i = 0;
gets(p);
while(p[i] != '\0')
{
if(p[i] == ' ')
num++;
i++;
}
num += 1;
printf("%d\n", num);
}
3/
#include <stdio.h>
void main()
{
int year;
scanf("%d",&year);
if ((year%4==0&&year%100!=0)||(year%400==0));
printf("%d 是闰年\n",year);
}
4/
#include <stdio.h>
void func(int *a, int *b)
{
int tmp;
if(*a < *b)
{
tmp = *a;
*a = *b;
*b = tmp;
}
}
int main()
{
int a, b;
scanf("%d %d", &a, &b);
func(&a, &b);
printf("%d %d\n", a, b);
return 0;
}
写的急,刚才第一题数组赋值的时候少写一列,已修改(都是最简单的应付考试的写法,不是很规范,但执行没问题)本回答被提问者和网友采纳