C++程序代码帮忙加一个数据输入

来源:百度知道 编辑:UC知道 时间:2024/05/23 12:45:34
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout<<"***** Welcome to 512 KTV *****" << endl;
while(1){
cout<<"1--查看 2--点歌 3--推出"<< endl;
int a;
cin>>a;
if(a==1)
{
cout<<"1.爱你一万年"<< endl;
cout<<"2.中国人"<< endl;
cout<<"3.同一首歌"<< endl;
cout<<"4.童年"<< endl;
}
if(a==2)
{
cout<<"Please select:"<< endl;
int b;
cin>>b;
if(b==1)
{
cout<<"1.爱你一万年"<< endl;
}
if(b==2)
{
cout<<"2.中国人"<< endl;
}
if(b==3)
{
cout<<"3.同一首歌"<< endl;
}
if(b==4)
{
cout<<"4.童年"<< endl;
}
}
if(a==3)
br

#include <iostream>
#include <string>
using namespace std;

class songs{
char* name;
static songs *head;
songs *next;
public:
static void PrintList();
static void add(char*);
static void remove(int);
static void edit(int);
static void playing(int);
};

void songs::PrintList(){
songs *tail;
int n=1;
tail=head;
if (!tail)
cout<<"空的歌曲列表"<<endl;
else{
while (tail){
cout<<n<<"."<<tail->name<<endl;
tail=tail->next;
n++;
}
}
}

void songs::add(char* tem){
songs *tail;
tail=head;
if (!head){ //beginning of the list
head=new songs;
head->name=new(char[strlen(tem)+1]);
strcpy(head->name,tem);
head->next=NULL;
}
else{
while (tail->next)
tail=tail->next;
tail->next=new songs;
tail=tail-&