65,209
社区成员
发帖
与我相关
我的任务
分享#include <afx.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
void main()
{
cout<<"sizeof(char):"<<sizeof(char)
<<" sizeof(WCHAR):"<<sizeof(WCHAR)<<endl;
char a[]="char";
cout<<a<<endl;
WCHAR b[]=L"WCHAR";
cout<<b<<endl;
char *c=new char;
c=a;
cout<<c<<endl;
WCHAR *d=new WCHAR;
d=b;
cout<<d<<endl;
CString e="cstring";
cout<<e<<endl;
cout<<sizeof(e[0])*e.GetLength()+1<<endl;
CString f=L"Lcstring";
cout<<f<<endl;
cout<<sizeof(f[0])*f.GetLength()+1<<endl;
system("pause");
}#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;
}