项目3:矩阵求和.
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include<iostream> using namespace std; int main() { int a[3][3]={1,2,3,4,5,6,7,8,9}; int sum=0,i=0,j=0; for(i=0;i<3;i++) { for(j=0;j<3;j++) { if((i+j)%2==0) { sum+=a[i][j]; } } } cout<<"两条对角线上的元素之和为:"<<sum<<endl; return 0; }
项目5:字符串操作.
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include<iostream> using namespace std; int main() { char a[6],b[6]; cout<<"输入两个字符串:"<<endl; cin>>a>>b; int i=0,j=0; for(i=0;i<6;i++) { if(a[i]!=b[i]) { cout<<"这两个字符串不等"<<endl; break ; } i++; } if(i==6) cout<<"这两个字符串相等"<<endl; cout<<a<<b<<endl; }
最后
以上就是默默御姐最近收集整理的关于C++第六次作业的全部内容,更多相关C++第六次作业内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复