c++作业6
来源:互联网 发布:逆转三国上古神迹数据 编辑:程序博客网 时间:2024/05/16 05:27
项目一——数组操作
#include <iostream>using namespace std;int main(){ int i,j,t,a[10]= {5,6,9,7,4,8,3,1,2,0}; int x,y; int z,locate,value; for(i=0; i<9; i++) for(j=0; j<9-i; j++) { if(a[j]>a[j+1]) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; } } for(i=0; i<10; i++) cout<<a[i]<<" "; cout<<endl; cout<<"请输入要删除的数:"; cin>>y; for(x=y; x<9; x++) a[x]=a[x+1]; for(x=0; x<9; x++) cout<<a[x]<<" "; cout<<endl; cout<<"插入数的位置为:"; cin>>locate; cout<<"插入的数为:"; cin>>value; for(z=9; z>locate; z--) a[z]=a[z-1]; a[z]=value; for(z=0; z<10; z++) cout<<a[z]<<" "; return 0;}项目三——矩阵求和
#include <iostream>using namespace std;int main(){ int i,sum1,sum2,a[3][3]= {8,9,3,6,4,6,7,3,9}; for(i=0; i<3; i++) sum1=sum1+a[i][i]; for(i=0; i<3; i++) sum2=sum2+a[i][2-i]; cout<<"一条对角线的和为:"<<sum1<<"\n"; cout<<"另一条对角线的和为:"<<sum2<<endl; return 0;}
1 0
- c++-作业6
- C语言程序设计课后作业6
- c 作业
- c作业
- C作业
- c作业
- c作业
- c作业
- c作业
- c作业
- C++P27作业3,4,5,6
- C++P51作业1,3,4,6
- C语言作业-6-1分解质因数
- C语言作业-6-2完数
- XTU C语言程序设计实践作业6
- 【C语言】【unix c】作业 前台作业和后台作业
- 作业:C++作业6
- C语言期中作业
- 【IIS问题】——默认网站localhost无法打开,错误类型404
- 文章标题
- Linux-内核模块开发
- 《深入理解Linux 内核》 chap 1 绪论
- HOOJ1290 2050(递推)
- c++作业6
- Android Notification的基本应用 (8.1)
- HTML---网络编程基础知识(2)
- Android高级UI SwipeRefreshLayout下拉刷新
- HDU 5583 Kingdom of Black and White [Ad Hoc]
- hdu1556Color the ball(线段树)
- go语言的变量声明
- 逻辑运算符与关系运算符
- hihoCoder 1287 Miller-Rabin质数测试