标题:[求助]如何才能正确的按设计方案向其中输入数据呢?
只看楼主
wyp
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-5-13
 问题点数:0 回复次数:0 
[求助]如何才能正确的按设计方案向其中输入数据呢?

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


class School
{
public:
char* sname;
int num;
int totalscore;
School(char* sname,int num)
{
this->sname=sname;
this->num=num;
}
void disp()
{
cout<<sname<<"("<<num<<")"<<endl;
}
};

class ManMatch
{
char* mname;
int mno;
ManMatch(char* mname,int mno)
{
this->mname=mname;
this->mno=mno;
}
void display()
{
int m=1;
cout<<"男子竞赛项目"<<m<<endl;
cout<<mname<<endl;
cout<<"代号:"<<mno<<endl;
m++;
}
};

class WomanMatch
{
char* wname;
int wno;
WomanMatch(char* wname,int wno)
{
this->wname=wname;
this->wno=wno;
}
void display()
{
int w=1;
cout<<"女子竞赛项目"<<w<<endl;
cout<<wname<<endl;
cout<<"代号:"<<wno<<endl;
w++;
}
};
void main()
{
int N=0,M=0,W=0,i=1,j=1,k=1,a=0,b=0,c=0;
int num;
char * name=NULL;
float score=0;

cout<<"请输入:"<<endl;
cout<<"参赛学校总数 "<<"男子竞赛项目数 "<<"女子竞赛项目数 "<<endl;
cin>>N>>M>>W;
int s[]={0};
cout<<"请填写比赛结果:"<<endl;
for(i=1;i<=M;i++)
{
cout<<"男子竞赛项目"<<i<<"的比赛结果"<<endl;
for(j=1;j<=5;j++)
{
cout<<" 第"<<j<<"名:"<<endl;
cout<<"姓名 "<<"比赛成绩 "<<"所在学校代号"<<endl;
cin>>name>>score>>num;


switch(j)
{

case 1:
for(k=1;k<=N;k++)
{
if(num==s[k-1]){
s[k-1]+=7;
break;
}
}
break;
case 2:
for(k=1;k<=N;k++)
{
if(num,s[k-1]){
s[k-1]+=5;
break;
}
}
break;
case 3:
for(k=1;k<=N;k++)
{
if(num,s[k-1]){
s[k-1]+=3;
break;
}
}
break;
case 4:
for(k=1;k<=N;k++)
{
if(num,s[k-1]){
s[k-1]+=2;
break;
}
}
break;
case 5:
for(k=1;k<=N;k++)
{
if(num,s[k-1]){
s[k-1]+=1;
break;
}
}
break;
}
}
}

for(a=1;a<=M;a++)
{
cout<<"女子竞赛项目"<<a<<"的比赛结果"<<endl;
for(b=1;b<=5;b++)
{
cout<<" 第"<<b<<"名:"<<endl;
cout<<"姓名:"<<endl;cin>>name;
cout<<"比赛成绩:"<<endl;cin>>score;
cout<<"所在学校代号:"<<endl;cin>>num;

switch(b)
{

case 1:
for(c=1;c<=W;c++)
{
if(num,s[c-1]){
s[c-1]+=7;
break;
}
}
break;
case 2:
for(c=1;c<=N;c++)
{
if(num,s[c-1]){
s[c-1]+=5;
break;
}
}
break;
case 3:
for(c=1;c<=N;c++)
{
if(num,s[c-1]){
s[c-1]+=3;
break;
}
}
break;
case 4:
for(c=1;c<=N;c++)
{
if(num,s[c-1]){
s[c-1]+=2;
break;
}
}
break;
case 5:
for(c=1;c<=N;c++)
{
if(num,s[c-1]){
s[c-1]+=1;
break;
}
}
break;
}
}
}
}

搜索更多相关主题的帖子: 设计方案 数据 输入 
2007-07-13 15:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-155108-1-1.html




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

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