/*
*Copyright(c)2014,烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作者:满星辰
*完成日期:2014年 11月 20日
*版本号:v1.0
*
*问题描述:输出数组值为3的倍数 下标为3的倍数
*程序输入:
*程序输出:
*/
#include <iostream>
#include <cstdio>
using namespace std;</p><p>int main()
{
int a[16]= {332,221,723,123,187,13,90,45,96,0,45,25,65,45,89,78};
cout<<"数组中,元素值为3的倍数的是:"<<endl;
for(int i=0; i<=15; ++i)
{
if(a[i]%3==0)cout<<"a["<<i<<"] "<<a[i]<<endl;
}
cout<<"数组中,下标为3的倍数的是:"<<endl;
for(int j=0; j<=15; ++j)
{
if(j%3==0)cout<<"a["<<j<<"] "<<a[j]<<endl;
}
return 0;
}
运行结果: