zoukankan      html  css  js  c++  java
  • 1.4条件和循环

    代码练习

    > c++中
    > 换行符"endl"该符号与" "的区别:
    > "endl"除了具备" "的区别外,
    > 还调用输出流flush函数,刷新缓冲区,让数据直接写入文件或者屏幕上。
    > 这两种都可以用的。
    > 不过如果需要立即显示,比如输入到显示器的场合,最好用"endl",如果不需要立即显示,并且要兼顾代码的执行效率的时候,可以考虑 ,这样不刷新缓冲区,会更快。
    > 同理,由于没有调用输出流的fflsh函数来刷新缓冲区,所以这时的数据可能被存在缓冲区里,没有立即写入设备。
    >

    `#include
    #include
    using namespace std;
    int main()
    {
    string user_name;

    cout << "please enter your name:";
    cin >> user_name;
    

    switch (user_name.size())
    {
    case 0:
    cout << "Ah, the user with no name."
    << "well,ok,hi,user with no name ";
    break;
    case 1:
    cout << "A 1-character name? Hmm,have you read Kafka?"
    << "Hello," << user_name << endl;
    break;
    default:
    cout&lt;&lt;"Hello,"&lt;<user_name <<="" "--happy="" to="" make="" your="" acquaintance! ";="" break;="" }="" return="" 0;="" }`="" 值得注意switch中国每个case都要有一个break,如果没有将会发生贯穿现象。="" <img="" id="img1586251495245" src="file://C:Usersss1AppDataRoamingxiangxuemaxxm7img1586251495245.png" data-cnblogs="https://img2020.cnblogs.com/other/1519829/202004/1519829-20200408085834728-834760515.png">

    </user_name>

  • 相关阅读:
    开源围棋A.I. FoolGo
    再写围棋的MC模拟
    棋串的数据结构
    一种Lua到C的封装
    用vim写ios程序
    一种C函数到Lua的封装
    Unix命令
    RSA java rsa加密,解密,生成密钥对工具类
    UOS 开启远程登录
    UOS 设置 java 程序开机启动
  • 原文地址:https://www.cnblogs.com/HL77961/p/12657838.html
Copyright © 2011-2022 走看看