标签:for put turn define ret scanf ber inpu ++
累加
#include <stdio.h>
#define MAX 10
int main() {
int n;
int a[MAX];
int sum = 0;
printf("Input the number of figure(<=10):\n");
scanf("%d",&n);
for(int i = 0; i < n; i++){
scanf("%d",&a[i]);
}
for(int i = 0; i < n; i++){
sum += a[i];
}
printf("%d",sum);
return 0;
}
累乘
#include <stdio.h>
#define MAX 10
int main() {
int n;
int a[MAX];
int sum = 1;
printf("Input the number of figure(<=10):\n");
scanf("%d",&n);
for(int i = 0; i < n; i++){
scanf("%d",&a[i]);
}
for(int i = 0; i < n; i++){
sum *= a[i];
}
printf("%d",sum);
return 0;
}
标签:for put turn define ret scanf ber inpu ++
原文地址:https://www.cnblogs.com/AdvacneQxj/p/12826353.html