64,639
社区成员
发帖
与我相关
我的任务
分享
cout.imbue(locale("chs"));
试下加一行#include <stdio.h>
#include <iostream>
#include "LinkList.h"
using std::cout;
using std::endl;
using std::cin;
int main()
{
_tsetlocale(LC_ALL, _T("chs"));
LinkList L;
cout << "1.链表初始化" << endl;
InitList(L);
cout << "初始化成功" << endl;
cout << endl;
cout << "2.前插法创建链表" << endl;
CreateList_H(L, 5);
cout << "检查:" << endl;
OutputList(L);
cout << endl;
cout << "3.后插法创建链表" << endl;
CreateList_R(L, 5);
cout << "检查:" << endl;
OutputList(L);
cout << endl;
cout << "4.取值函数" << endl;
cout << "取第i个元素,i = ";
int i;
cin >> i;
cout << endl;
int e;
GetElem(L, i, e);
cout << "第三个元素为" << e << endl;
cout << endl;
cout << "5.插入函数" << endl;
cout << "插入到第i个元素,i0 = ";
int i0;
cin >> i0;
cout << endl;
cout << "插入值为: ";
int d;
cin >> d;
ListInsert(L, i, d);
cout << endl;
cout << "检查:" << endl;
OutputList(L);
cout << endl;
cout << "6.查找函数" << endl;
cout << "查找的数据值为:";
int d0;
cin >> d0;
cout << endl;
cout << "该元素在第 " << LocateELem(L, d0) << " 个位置。"
<< endl;
cout << endl;
cout << "7. 删除函数" << endl;
cout << "删除第几个函数:";
int i1;
cin >> i1;
cout << endl;
ListDelete(L, i1);
cout << "检查:" << endl;
OutputList(L);
return 0;
}
#2 其实就是一个很简单的 单链表 测试代码,和其他的成功运行的代码没什么两样
比如下面是没有出现乱码的一个cpp
#include <stdio.h>
#include <iostream>
#include "SequenceList.h"
using std::cout;
using std::endl;
int main()
{
SqList L;
cout << "▼1"
<< endl
<< "▲函数 InitList 测试..."
<< endl
<< "初始化顺序表 L ..." << "初始化成功!"
<< endl;
InitList(L);
cout << "Press any key..." <<endl;
getchar();
cout << "▼2"
<< endl
<< "▲函数 ListInsert&GetElem 测试..."
<< endl;
for(int i=1; i<=6; i++)
{
cout << "作为示范,在L第" << i << "个位置插入数据元素" << 2*i
<< endl;
ListInsert(L, i, 2*i);
}
cout << "顺序表元素输出:";
for(int i=0; i<L.length; i++)
cout << "L[" << i+1 <<"] = " << GetElem(L, i+1)
<< endl;
cout << "Press any key..." <<endl;
getchar();
cout << "▼3"
<< endl
<< "▲函数 ListDelete&LocateElem 测试..."
<< "删除值为6的元素"
<< endl;
ListDelete(L, LocateElem(L, 6));
cout << "顺序表元素输出:";
for(int i=0; i<L.length-1; i++)
cout << "L[" << i+1 <<"] = " << GetElem(L, i+1)
<< endl;
return 0;
}
#include <locale.h>
int main()
{
_tsetlocale(LC_ALL, _T("chs"));
}