1701H210.27 王建瑜 连续第四天

来源:互联网 发布:中国也门撤侨事件 知乎 编辑:程序博客网 时间:2024/05/17 04:44
练习string,如name.size(),name【n】,俩个“?”之间不可以直接连接,if()为真时执行{}内容。明天继续学习视频,复习
#include<iostream>
#include<stdlib.h>
#include<string>
using namespace std;

int main(void)
{
 string name;
 cout<<"please input your name:";
 getline(cin,name);
 if(name.empty())
 {
  cout<<"input is null.."<<endl;
  system("pause");
  return 0;
 }
 if(name == "imooc")
 {
  cout<<"you are a administrator"<<endl;
 }
 cout<<"hello"+name<<endl;
 cout<<"your name length:"<<name.size()<<endl;
 cout<<"your name first letter is:"<<name[0]<<endl;

    system("pause");
    return 0;

 }
阅读全文
0 0