c++第六次实验
2016-05-27 20:59
387 查看
二.字符串操作 [cpp] view plain copy 在CODE上查看代码片派生到我的代码片 <pre name="code" class="cpp">#include<iostream> #include <string> using namespace std; int main() { string a; string b; cout<<"请输入字符串:a="; cin>>a; cout<<"请输入字符串:b="; cin>>b; if(a==b) cout<<"两个字符串相等"<<endl; else cout<<"两个字符串不相等"<<endl; cout<<"字符串ab为"<<a+b<<endl; return 0; }
#include<iostream> using namespace std; int main() { int a[5]={1,3,8,9,10},b[5]={2,3,4,5,6},c[10],i,j,t; for(i=0; i<5; i++) { c[i] = a[i]; } for(i=5; i<10; i++) { c[i] = b[i-5]; } for(i=0; i<9; i++) for(j=0; j<9-i;j++) { if(c[j] > c[j+1]) { t = c[j]; c[j] = c[j+1]; c[j+1] = t; } } cout<<"数组a为a[5]=1 3 8 9 10"<<endl; cout<<"数组b为b[5]=2 3 4 5 6"<<endl; cout<<"数组c为:"; for(i=0; i<10; i++) { cout<<c[i]<<" "; } cout<<endl; return 0; }
相关文章推荐
- C语言中32个关键字
- 用c语言写的简单计算器
- c++作业6
- 树状数组及其应用(2)
- L1-011.A-B
- 基于C语言sprintf函数的深入理解
- c语言中的read和write函数
- ROS_Kinetic_12 ROS程序基础Eclipse_C++(三)usb camera
- ROS_Kinetic_12 ROS程序基础Eclipse_C++(三)usb camera
- ROS_Kinetic_12 ROS程序基础Eclipse_C++(三)usb camera
- POJ 2686-Traveling by Stagecoach(DAG图-状态压缩DP)
- 1021. 个位数统计 (15)
- 第十二周【形状类族的中的纯虚函数】
- C++头文件一览
- C++ char数组
- c++统计程序运行时间的方法
- C++实现base64编码
- 从事C和C++开发者快速学python(一)
- 今天对二级指针的深入理解
- L1-006. 连续因子(C++)