zoukankan      html  css  js  c++  java
  • 参数的书写要完整,不要贪图省事只写参数的类型而省略参数名字

    参数的书写要完整,不要贪图省事只写参数的类型而省略参数名字。

     1 #include <iostream>
     2 #include <string>
     3 
     4 using namespace std;
     5 
     6 //测试字符串(string)对象
     7 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     8 
     9 int main(int argc, char** argv) {
    10       //创建string对象
    11     string s1,s2;
    12 
    13     //string对象的赋值运算
    14     s1="One";
    15     s2="Two";
    16     cout<<"s1="<<s1<<endl;
    17     cout<<"s2="<<s2<<endl;
    18 
    19     //string对象的连接运算
    20     string s3;
    21     s3=s1+" and "+s2;
    22     cout<<"s3="<<s3<<endl;
    23 
    24     //组合赋值连接运算
    25     s3+=" and Three";
    26     cout<<"s3="<<s3<<endl;
    27 
    28     //比较运算及其结果显示
    29     for (int i=1;i<=3;i++) {
    30         cout<<"---------------------"<<endl;
    31         cout<<"s1=";
    32         cin>>s1;
    33         cout<<"s2=";
    34         cin>>s2;
    35         if (s1<s2)   //小于
    36             cout<<s1<<" < "<<s2<<endl;
    37         if (s1<=s2)  //小于等于
    38         cout<<s1<<" <= "<<s2<<endl;
    39         if (s1==s2)  //等于
    40         cout<<s1<<" == "<<s2<<endl;
    41         if (s1>s2)   //大于
    42         cout<<s1<<" > "<<s2<<endl;
    43         if (s1>=s2)  //大于等于
    44         cout<<s1<<" >= "<<s2<<endl;
    45         if (s1!=s2)  //不等
    46             cout<<s1<<" != "<<s2<<endl;
    47     }
    48     return 0;
    49 }
  • 相关阅读:
    液晶显示器分辨设置,显示器分辨率设置……
    如何显示语言栏
    查看一键Ghost的备份文件
    百度空间的变迁
    CentOS U盘安装
    Linux服务器系统选择
    博客一夜回到解放前
    spark常见的transformation和action算子
    二分查找
    9:两个栈实现一个队列
  • 原文地址:https://www.cnblogs.com/borter/p/9413545.html
Copyright © 2011-2022 走看看