请高手帮着改一下,C++程序

2025-05-12 23:21:09
推荐回答(3个)
回答(1):

if(i=='0')
break;
}
return 0;
}
while(i)
{
cout<<"please choose the num 0~6:\n";
这个地方没有看懂?
是不是少了个括号?还有i为int型 怎么能和字符比较?

回答(2):

这个错误太多了,中间cin<<,cout>>这样的错误就很多。括号也不对。for循环的用法也错了。
建议重写

回答(3):

错误太多了 我改了一下 但是不能输出正确结果 楼主好好再看一下吧 现在可以输出界面了
#include
#include
#include
#include
#include
#include
using namespace std;
struct people
{
//int sum;
int num;
char name[10];
char sex[6];
int age;
char workplace;
int roomnumber;
}peo[100];

void start()
{
system("cls");
cout<<"------------会议管理系统---------\n";
cout<<"--------------操作选单-------------\n";
cout<<" 1.参会人员信息登记 \n";
cout<<" 2.修改报道人员信息 \n";
cout<<" 3.注销报道人员信息 \n";
cout<<" 4.统计报道人员信息 \n";
cout<<" 5.显示报道人员信息 \n";
cout<<" 6.查询报道人员信息 \n";
cout<<" 0.退出 \n";
}

int main()
{
int sum=0;
start();
int i=0,n,k;
string b="zanbao12";
string a;
cout<<"please enter the password:\n";
cin>>a;
if(a==b)
{
cout<<"your password is right!\n";
i=1;
}
else
{
cout<<"your password is wrong!\n";
cout<<"exit or go on:\n";
i=getch();
if(i==0)exit(-1);
}
//return 0;

while(i)
{
cout<<"please choose the num 0~6:\n";
//cin>>i;
i=getch();
switch(i)
{
case'1':
//int i=0;
for(i=0;i{
cout<<"please enter the name:\n";
cin>>peo[i].name;
cout<<"please enter the sex:\n";
cin>>peo[i].sex;
cout<<"please enter the age:\n";
cin>>peo[i].age;
cout<<"please enter the workplace:\n";
cin>>peo[i].workplace;
cout<<"please enter the roomnumber:\n";
cin>>peo[i].roomnumber;
sum++;
}
break;

case'2':
cout<<"请输入要修改的人员的号码:\n";
cin>>k;
if(peo[i].num==k)
{
cout<<"\n请修改:\n name:";
cin>>peo[k].name;
cout<<"sex:";
cin>>peo[k].sex;
cout<<"age:";
cin>>peo[k].age;
cout<<"workplace:";
cin>>peo[k].workplace;
cout<<"roomnumber:";
cin>>peo[k].roomnumber;
}
break;
case'3':
cout<<"请输入要注销的人员的号码:\n";
cin>>k;
for(i=0;i{
if(peo[i].num==k)
for(;i{
peo[i].num=peo[i+1].num;
strcpy(peo[i].name,peo[i+1].name);
peo[i].age=peo[i+1].age;
}
}
n=n-1;break;

case'4':
cout<<"统计报道人员的数量:\n:";
//cin>>n;
//for(k=0;kcout<break;

case'5':
cout<<"num\n name\t sex\t age\t woekplace\t roomnumber\n";
for(i=1;ibreak;

case'6':
cout<<"请输入需要查询的人员号码:\n";
cin>>k;
cout<cout<cout<cout<cout<break;
case'0':break;
//if(i==0)
//break;
return 0;
}
}
}