1 条题解
-
0
C :
#include <stdio.h> int main(int argc, char const *argv[]) { int a[100]; int sum = 0; for (int i = 0; i < 100; ++i) { scanf("%d",&a[i]); if (a[i] % 2 != 0 ) sum += a[i]; } printf("数组a中所有奇数之和%d\n",sum); return 0; }
C++ :
#include<iostream> using namespace std; #define N 100 int main() { int a[N]; //array int sum = 0; for(int i=0; i<N; ++i){ cin >> a[i]; } for(int i=0; i<N; ++i){ if(a[i] %2 != 0){ sum += a[i]; } } cout << "数组a中所有奇数之和" << sum << endl; return 0; }
Pascal :
var a:array[0..100] of longint; n,i,c:longint; begin for i:=1 to 100 do begin read(a[i]); if odd(a[i]) then c:=c+a[i]; end; writeln('数组a中所有奇数之和',c); end.
- 1
信息
- ID
- 1672
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者