done
This commit is contained in:
parent
984d2c30f0
commit
a91c649ef7
18
0410/10.c
Normal file
18
0410/10.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void fun(int a, int b, int *sum, int *diff, int *product, float *divide) {
|
||||||
|
*sum = a + b;
|
||||||
|
*diff = a - b;
|
||||||
|
*product = a * b;
|
||||||
|
*divide = (float)a / b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int a, b;
|
||||||
|
int sum, diff, product;
|
||||||
|
float divide;
|
||||||
|
scanf("%d %d", &a, &b);
|
||||||
|
fun(a, b, &sum, &diff, &product, ÷);
|
||||||
|
printf("%d %d %d %.2f\n", sum, diff, product, divide);
|
||||||
|
return 0;
|
||||||
|
}
|
31
0410/11.c
Normal file
31
0410/11.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#define for_i(i, range, inner) \
|
||||||
|
{ \
|
||||||
|
int i; \
|
||||||
|
for (i = 0; i < range; i++) \
|
||||||
|
inner; \
|
||||||
|
}
|
||||||
|
|
||||||
|
int search(int x[], int n, int *count) {
|
||||||
|
int cnt = 0, max_num = -1;
|
||||||
|
for_i(i, n, {
|
||||||
|
if (x[i] > max_num) {
|
||||||
|
max_num = x[i];
|
||||||
|
cnt = 1;
|
||||||
|
} else if (x[i] == max_num) {
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*count = cnt;
|
||||||
|
return max_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int n, count, max_num;
|
||||||
|
int x[1005];
|
||||||
|
scanf("%d", &n);
|
||||||
|
for_i(i, n, scanf("%d", &x[i]));
|
||||||
|
max_num = search(x, n, &count);
|
||||||
|
printf("%d %d\n", max_num, count);
|
||||||
|
return 0;
|
||||||
|
}
|
23
0410/9.c
Normal file
23
0410/9.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#define for_i(i, range, inner) \
|
||||||
|
{ \
|
||||||
|
int i; \
|
||||||
|
for (i = 0; i < range; i++) \
|
||||||
|
inner; \
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int m, n, max_m, max_n, max_num = -1, *p;
|
||||||
|
scanf("%d %d", &m, &n);
|
||||||
|
for_i(i, m, for_i(j, n, {
|
||||||
|
int num;
|
||||||
|
scanf("%d", &num);
|
||||||
|
if (num > max_num) {
|
||||||
|
max_num = num;
|
||||||
|
max_m = i;
|
||||||
|
max_n = j;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
printf("%d %d %d\n", max_num, max_m + 1, max_n + 1);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user