/*
* Copyright (c) 2014,烟台大学计算机学院
* All right reserved.
*文件名:thirteen week 1.3.app
* 作者:柴银平
* 完成时间:2014年11月24日
* 版本号:v1.0
*
* 问题描述:程序先输出数组元素里是3倍数的数,然后再输出下标是3的倍数的元素的值
*程序输入:
*程序输出:先输出是3倍数的元素值,后再输出下标是3倍数的元素值
*/
#include <iostream>
using namespace std;
int main()
{
int i;
int a[16]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
cout<<"数组中,元素值为3的倍数的数是:"<<endl;
for (i=0; i<16; i++)
{
if (a[i]%3==0)
cout<<"a"<<"["<<i<<"]"<<" "<<a[i]<<endl;;
}
cout<<endl;
cout<<"下标为3的倍数的元素值:"<<endl;
for (i=0; i<16; i++)
{
if (i%3==0&&i!=0)
cout<<"a"<<"["<<i<<"]"<<" "<<a[i]<<endl;
}
cout<<endl;
return 0;
}
学习心得:
加油吧!至少简单的要会!