| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 576 人关注过本帖
标题:[原创]输出乱码的原因
只看楼主 加入收藏
CNick
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-5-16
收藏
 问题点数:0 回复次数:0 
[原创]输出乱码的原因

#include<iostream>
using namespace std;
struct node
{


/**
node(int *y,char *s,int x,node *link)
{
for(int a=0,b=0;y[a]!=-1;a++,b++)
music[b]=y[a];
name=s;
i=x;
next=link;
}
/**/

int music[10];
char name[10]; // 改过
int i;
node *next;
};

class LinkList
{
public:
LinkList()
{
first=NULL;
n=0;
}
void Insert(int pos,int m[],char str[]);
void Setup();
void Display();
void Play(node *p);
int length()
{
return n;
}
node* SetPos(int pos);
protected:
node *first;
int n;
};

node* LinkList::SetPos(int pos)
{
node *q=first;
for(int i=0;i<pos;i++)
q=q->next;
return q;
}

void LinkList::Setup()
{
node *q,*p;
int xiaomifeng[]={1,2,3,4,5,-1};
// q=new node(xiaomifeng,"小蜜蜂",1,NULL);
q=new node;
q->i=1;
memcpy(q->music,xiaomifeng,sizeof(q->music));
strcpy(q->name,"小蜜蜂");
q->next=first;
first=q;

int yujian[]={5,4,3,2,1,-1};
p=new node;
p->i=2;
::memcpy(p->music,yujian,sizeof(p->music));
::strcpy(p->name,"遇见");
p->next=q->next;
q->next=p;

// p=new node(yujian,"遇见",2,NULL);
// p->next=q->next;
// q->next=p;

n+=2;
}

void LinkList::Play(node *p)
{
node *q=p;
int i=0;
while(q->music[i]!=-1)
{
cout<<q->music[i++];
}

cout<<endl;
}


void LinkList::Insert(int pos,int m[],char str[])
{
node *p,*q;
p=new node;
p->i=pos+1;
::memcpy(p->music,m,sizeof(p->music));
::strcpy(p->name,str);
if(pos>0)
{
q=SetPos(pos-1);
p->next=q->next;
q->next=p;
}
else
{
p->next=first;
first=p;
}
n++;
}


void LinkList::Display()
{
node *m=first;
int j;
cout<<"歌曲列表\n";
for(int a=1;a<=n;a++)
{
cout<<a<<'.'<<m->name<<endl;
m=m->next;
}
cout<<"按-1可以退到上一级别菜单\n";
cout<<"请选择:";
cin>>j;
while(j>0)
{
j=j-1;
node *z=SetPos(j);
Play(z);
cout<<"歌曲列表\n";
node *f=first;
for(int a=1;a<=n;a++)
{
cout<<a<<'.'<<f->name<<endl;
f=f->next;
}
cout<<"按-1可以退到上一级别菜单\n";
cout<<"请选择:";
cin>>j;
}

}
int main()
{
LinkList nick;
int w,x,y,z=0;
int s[100];
char str[10];
nick.Setup();
cout<<"**********************************欢迎使用此软件********************************\n";
cout<<" 1.点播歌曲\n";
cout<<" 2.自己写歌\n";
cout<<" 3.退出系统\n\n\n";
cout<<" 请做出选择....:";
cin>>x;
while(x>0)
{
if(x==1)
nick.Display();
if(x==2)
{
cout<<"请输入这是第几首歌:";
cin>>w;
cout<<"请输入歌曲的音阶以-1结束:";
cin>>y;
while(y!=-1)
{
s[z]=y;
z++;
cin>>y;
}
s[++z]=y;
cout<<"请输入歌名:";
cin>>str;
w=w-1;
nick.Insert(w,s,str);
}


if(x==3)
{
cout<<" 欢迎再次使用!\n";
break;
}
cout<<"**********************************欢迎使用此软件********************************\n";
cout<<" 1.点播歌曲\n";
cout<<" 2.自己写歌\n";
cout<<" 3.退出系统\n\n\n";
cout<<" 请做出选择....:";
cin>>x;
}
return 0;
}

进入第2个功能数组输入完毕后返回点播歌曲输出刚刚输入的数组时出现乱码..........为什么?????????

搜索更多相关主题的帖子: 乱码 输出 
2006-07-02 11:10
快速回复:[原创]输出乱码的原因
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014741 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved