#include <iostream> using namespace std; int main() { int a[5] = { 1, 3, 5, 7, 9 }; int sm = 0; //注意这里要给默认值 for (int i = 0; i < 5; i++) { sm += a[i]; cout << "a[i]=" << a[i] << ", sm=" << sm << endl; } return 0; }
原文地址:https://www.cnblogs.com/chen55555/p/12209746.html
时间: 2024-11-10 14:45:42