#include"iostream.h"
#include"stdlib.h"
void main()
{
int result1,result2,result3;
result1=result2=result3=0;
int **a;
int n;
char b;
cout<<"投票人数:";
cin>>n;
a=new int *[n];
cout<<"输入投票内容:"< for(int i=0;i a[i]=new int[3];
for(int j=0;j {
for(int k=0;k<3;k++)
{
cin>>b;
a[j][k]=b;
}
if(a[j][0]==a[j][1]||a[j][0]==a[j][2]||a[j][1]==a[j][2])
{
cout<<"该票无效 !"< a[j][0]=a[j][1]=a[j][2]=0;
}
else
{
if(a[j][0]=='a')result1+=5;
else if(a[j][0]=='b')result2+=5;
else if(a[j][0]=='c')result3+=5;
if(a[j][1]=='a')result1+=3;
else if(a[j][1]=='b')result2+=3;
else if(a[j][1]=='c')result3+=3;
if(a[j][2]=='a')result1+=2;
else if(a[j][2]=='b')result2+=2;
else if(a[j][2]=='c')result3+=2;
}
}
if(result1==result2||result1==result3||result2==result3)
{
cout<<"重新投票"< }
else
{
cout<<"三位候选人得分:";
cout<<"a:"< cout<<"b:"< cout<<"c:"< if(result1>result2&&result1>result3)
cout<<"祝贺a当选冠军!";
else if(result2>result1&&result2>result3)
cout<<"祝贺b当选冠军!";
else
cout<<"祝贺c当选冠军!";
}
}
--------------------next---------------------
#include"stdio.h"
#include"stdlib.h"
void main()
{
int result1,result2,result3;
result1=result2=result3=0;
int **a;
int n;
char b;
printf("投票人数:");
scanf("%d",&n);
a=new int *[n];
for(int i=0;ia[i]=new int[3];
printf("输入投票内容:\n");
for(int j=0;j{
for(int k=0;k<3;k++)
{
scanf("%s",&b);
a[j][k]=b;
}
if(a[j][0]==a[j][1]||a[j][0]==a[j][2]||a[j][1]==a[j][2])
{
printf("该票无效 !\n");
a[j][0]=a[j][1]=a[j][2]=0;
}
else
{
if(a[j][0]=='a')result1+=5;
else if(a[j][0]=='b')result2+=5;
else if(a[j][0]=='c')result3+=5;
if(a[j][1]=='a')result1+=3;
else if(a[j][1]=='b')result2+=3;
else if(a[j][1]=='c')result3+=3;
if(a[j][2]=='a')result1+=2;
else if(a[j][2]=='b')result2+=2;
else if(a[j][2]=='c')result3+=2;
}
}
if(result1==result2||result1==result3||result2==result3)
{
printf("重新投票! \n");
}
else
{
printf("三位候选人得分:");
printf("a:%d \n",result1);
printf("b:%d \n",result2);
printf("c:%d \n",result3);
if(result1>result2&&result1>result3)
printf("祝贺a当选冠军!");
else if(result2>result1&&result2>result3)
printf("祝贺b当选冠军!");
else
printf("祝贺c当选冠军!");
}
}
--------------------next---------------------
阅读(1229) | 评论(0) | 转发(0) |