一堆数组

数组声明:<存储类别><元素类型><数组名>[<元素个数>]

访问是按照<数组名>[<下标表达式>]

#include<iostream>
#define SIZE 10
using namespace std;
int main()
{
    int n[SIZE]={12,34,1,1,2,3,4,2,3,4};
    int i,sum;
    cout<<"Element"<<"\t value";
    for(i=0;i<SIZE-1;i++){
        cout<<"n["<<i<<"]="<<n[i]<<endl;
        sum +=n[i];
    }
    cout<<"the summary is:"<<sum<<endl;
    return 0; 
}

猜你喜欢

转载自www.cnblogs.com/duxinzoeACM/p/9812177.html
今日推荐