65,209
社区成员
发帖
与我相关
我的任务
分享
我也有这个问题
这个string inputString= Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(encodeBytes))也试过没用;
最后在
win10区域——管理——更改区域设置里面有个 Beta版:使用Unicode UTF-8提供全球语言支持的栏位;把前面的勾去掉重启一下就好了。
#include <iostream>
#include <string>
using namespace std;
class Student
{
public:
//属性
string m_Name;
string m_ID;
//行为
void Scanf()
{
string name;
cout << "接收键盘输入:" << endl;
cout << "请输入学生姓名:" << endl;
cin >> name;
m_Name = name;
string ID;
cout << "请输入学生学号:" << endl;
cin >> ID;
m_ID = ID;
}
void Printf()
{
cout << "输出:" << endl;
cout << "学生姓名:"<<m_Name << endl;
cout << "学生学号:" << m_ID << endl;
}
};
int main()
{
Student s1;
s1.Scanf();
s1.Printf();
system("pause");
return 0;
}#pragma warning(disable:4786)
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main () {
wstring ws1,ws2;
wcin.imbue(locale("chs"));
wcout.imbue(locale("chs"));
getline(wcin,ws1);
getline(wcin,ws2);
if (ws1.size()!=ws2.size()) {
wcout<<ws1<<L" 和 "<<ws2<<L" 不对应"<<endl;
return 1;
}
map<wchar_t,wchar_t> m1,m2;
int n=ws1.size();
for (int i=0;i<n;i++) {
if (m1.find(ws1[i])==m1.end() && m2.find(ws2[i])==m2.end()) {
m1[ws1[i]]=ws2[i];
m2[ws2[i]]=ws1[i];
} else {
if (m1[ws1[i]]!=ws2[i] || m2[ws2[i]]!=ws1[i]) {
wcout<<ws1<<L" 和 "<<ws2<<L" 不对应"<<endl;
return 1;
}
}
}
wcout<<ws1<<L" 和 "<<ws2<<L" 对应"<<endl;
return 0;
}