第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

有什么辦法解決輸入漢字時的首個漢字無法輸出的問題




/*************************************************************************/

/*題目描述:

? ? ? ? ? ?1. 提示用戶輸入姓名

? 2. 接收用戶的輸入

? 3. 然后向用戶問好, hello xxx

? 4. 告訴用戶名字的長度

? 5. 告訴用戶名字的首字母是什么

? 6. 如果用戶直接輸入回車那么告訴用戶的輸入為空

? 7. 如果用戶輸入的是imooc,那么告訴用戶的角色是一個管理員*/


#include"stdafx.h"

#include<iostream>

#include<stdlib.h>

#include<string>

using namespace std;




int main()

{

string name;

cout << "please input your name:" << name;

getline(cin, name);

if (name.empty())

{

cout << "input is null..." << endl;

return 0;

}

if (name == "imooc")

cout << "you are a administrator" << endl;

cout << "your name length :" << name.size() << endl;

cout << "your name first letter is :" << name[0] << endl;

return 0;

}


//未成熟版本 :漢字無法正常使用 輸入漢字時 一個漢字相當(dāng)于兩個字母長度 首字母無法輸出


正在回答

3 回答

#include<iostream>

#include<stdlib.h>

#include<string>

using namespace std;


int main()

{

string name;

cout << "please input your name:" << name;

getline(cin, name);

if (name.empty())

{

cout << "input is null..." << endl;

return 0;

}

if (name == "imooc")

cout << "you are a administrator" << endl;

cout << "your name length :" << name.size() << endl;

cout << "your name first letter is :" << name[0] <<name[1]<< endl;

return 0;

}

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

風(fēng)夢3176435 提問者

非常感謝!
2016-06-13 回復(fù) 有任何疑惑可以回復(fù)我~

為啥name【1】就可以打出第一個中文???還有個數(shù)為啥錯了?

#include<iostream>

#include<stdlib.h>

#include<string>

using namespace std;

int main(void)

{

string name;

cout << "please input your name :" << endl;

getline(cin, name);

if (name.empty())

{

cout << "please input your name:" << endl;

}

if (name == "imooc")

{

cout << "you are a administrator" << endl;

system("pause");

return 0;

}

cout << "hello" << " ?" << name << endl;

cout << "your name length is :" << name.size() << endl;

cout << "your name first letter is :" << name[0] << name[1] << endl;

system("pause");

return 0;

}


0 回復(fù) 有任何疑惑可以回復(fù)我~

為什么加了name【1】就可以打出第一個中文???

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
C++遠(yuǎn)征之封裝篇(上)
  • 參與學(xué)習(xí)       103386    人
  • 解答問題       732    個

封裝--面向?qū)ο蟮幕?,本教程力求幫助小伙伴們即學(xué)即會

進(jìn)入課程

有什么辦法解決輸入漢字時的首個漢字無法輸出的問題

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號