折腾二维数组
来源:互联网 发布:陈建年 知乎 编辑:程序博客网 时间:2024/05/18 04:23
#include<iostream>using namespace std ;int main (){ int i,j,k; int a[5][4]= {{0,1},{4,5},{8,9},{12,13},{16,17}}; cout<<"请输入后两列的10个元素:"<<endl; for(i=0; i<5; ++i) for(j=2; j<=3; ++j) cin>>a[i][j]; cout<<"数组中元素的值为:"<<endl; for(i=0; i<5; ++i) { cout<<"第"<<i<<"行:"; for(j=0; j<4; ++j) cout<<a[i][j]<<" "; cout<<endl; } cout<<"现在将所有元素乘以3倍。。。完成!"<<endl; for(i=0; i<5; ++i) { for(j=0; j<4; ++j) a[i][j]*=3; } cout<<"按行序优先输出:"<<endl; for(i=0; i<5; ++i) { cout<<"第"<<i<<"行:" ; for(j=0; j<4; ++j) cout<<a[i][j]<<'\t'; cout<<endl; } cout<<"按列序优先输出:"<<endl; for(j=0; j<4; ++j) { cout<<"第"<<j<<"列: "; for(i=0; i<5; ++i) cout<<a[i][j]<<'\t'; cout<<endl; } cout<<"将数组倒着输出:"<<endl; for(i=4; i>=0; --i) { cout<<"第"<<i<<"行: "; for(j=3; j>=0; --j) cout<<a[i][j]<<'\t'; cout<<endl; } cout<<"输出数组中所有偶数:"<<endl; for(i=0; i<5; ++i) { for(j=0; j<4; ++j) if(a[i][j]%2==0) cout<<"a["<<i<<"]["<<j<<"]="<<a[i][j]<<'\t'; cout<<endl; } cout<<"行列下标之和为3的倍数的值 :"<< endl; for(i=0; i<5; ++i) { for(j=0; j<4; ++j) { k=i+j; if(k%3==0) { cout<<"a["<<i<<"]["<<j<<"]="<<a[i][j]<<'\t'; cout<<endl; } } } return 0;}
0 0
- 二维数组大折腾
- 二维数组大折腾
- 折腾二维数组
- 二维数组大折腾
- 折腾二维数组
- 折腾二维数组
- 折腾二维数组
- 二维数组再折腾!!!
- 折腾二维数组
- 二维数组大折腾
- 折腾二维数组
- 二维数组大折腾
- 二维数组大折腾
- 折腾二维数组
- 折腾二维数组
- 折腾二维数组
- 折腾二维数组
- 二维数组大折腾
- Windows平台安装Beautiful Soup
- 使用memcached进行内存缓存
- Putty保存配置
- bat脚本启动程序
- 【c++程序】重载加法运算符operator+
- 折腾二维数组
- const char*, char const*, char*const的区别
- .net学习框架
- 时钟树解析
- 关于C里面 数字0,字符'0',字符串"0",字符串结尾标志符'\0'
- 进程之间不能传递指针。。
- container_of 的的的原理
- svn强制写日志和可以修改历史日志(svn钩子的应用)
- [iOS越狱开发]安装command line tools for Xcodew