zoukankan      html  css  js  c++  java
  • 如果某一常量与其它常量密切相关,应在定义中包含这种关系,而不应给出一些孤立的值

    如果某一常量与其它常量密切相关,应在定义中包含这种关系,而不应给出一些孤立的值。

    例如: const float RADIUS = 100; const float DIAMETER = RADIUS * 2;

     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;
    12     string s2="ABCDEFGHIJK";
    13     string s3=s2;
    14     string s4(20,'A');
    15     string s5(s2,3,3);
    16     cout<<"s1="<<s1<<endl;
    17     cout<<"s2="<<s2<<endl;
    18     cout<<"s3="<<s3<<endl;
    19     cout<<"s4="<<s4<<endl;
    20     cout<<"s5="<<s5<<endl;
    21 
    22     //为string对象输入数据,并显示
    23     cout<<"s1=";
    24     cin>>s1;
    25     cout<<"s2=";
    26     cin>>s2;
    27     cout<<"s3=";
    28     cin>>s3;
    29     cout<<"s4=";
    30     cin>>s4;
    31     cout<<"s5=";
    32     cin>>s5;
    33 
    34     cout<<"s1="<<s1<<endl;
    35     cout<<"s2="<<s2<<endl;
    36     cout<<"s3="<<s3<<endl;
    37     cout<<"s4="<<s4<<endl;
    38     cout<<"s5="<<s5<<endl;
    39     
    40     return 0;
    41 }
  • 相关阅读:
    c++数据类型
    c++注释
    c++基本语法
    c++环境配置
    c++简介
    9 HTTP和HTTPS
    12 RESTful架构(SOAP,RPC)
    剑指10二进制中1的个数
    第2章 新手必须掌握的Linux命令
    11个炫酷的Linux终端命令大全
  • 原文地址:https://www.cnblogs.com/borter/p/9413543.html
Copyright © 2011-2022 走看看