1个回答
展开全部
2.
#include <stdlib.h>
#include <time.h>
int fac (int n) {
return (n == 0) ? 1 : (n * fac (n - 1));
}
main () {
int a[10], s = 0;
srand ((unsigned)time (NULL));
for (int i = 0; i < 10; i++) {
a[i] = rand () % 10;
}
for (int j = 0; j <= 10; j++) {
if (~(a[j] & 1)) {
s += fac (a[j]);
}
}
printf ("The sum is %d\n", s);
}
3.
#include <stdlib.h>
#include <time.h>
main () {
int b[10];
srand ((unsigned)time (NULL));
for (int i = 0; i < 10; i++) {
b[i] = rand () % 90 + 10;
printf ("%d\t", b[i]);
}
int *max = b;
for (int j = 0; j < 10;j++) {
if (*max < b[j]) max = b + j;
}
printf ("\nmax=%d\n", *max);
}
#include <stdlib.h>
#include <time.h>
int fac (int n) {
return (n == 0) ? 1 : (n * fac (n - 1));
}
main () {
int a[10], s = 0;
srand ((unsigned)time (NULL));
for (int i = 0; i < 10; i++) {
a[i] = rand () % 10;
}
for (int j = 0; j <= 10; j++) {
if (~(a[j] & 1)) {
s += fac (a[j]);
}
}
printf ("The sum is %d\n", s);
}
3.
#include <stdlib.h>
#include <time.h>
main () {
int b[10];
srand ((unsigned)time (NULL));
for (int i = 0; i < 10; i++) {
b[i] = rand () % 90 + 10;
printf ("%d\t", b[i]);
}
int *max = b;
for (int j = 0; j < 10;j++) {
if (*max < b[j]) max = b + j;
}
printf ("\nmax=%d\n", *max);
}
追问
大神,求vb编码,C语言看不懂,❤❤❤
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询