文件名称:choose
介绍说明--下载内容均来自于网络,请自行研究使用
用c++编写的选票系统,并可统计相关得票情况-#include <iostream>
using namespace std
struct Person//声明结构体类型Person;
{
char name[20]
int count
}
int main()
{
Person leader[3]={"aaa",0,"bbb",0,"ccc",0}
//定义Person类型的数组,内容为当前候选人的姓名及得票数;
char leader_name[20] //leader_name为投票人所选的人姓名;
int i,j
for(i=0 i<10 i++)
{
cin>>leader_name //先后输入十张票上所选的人的姓名;
for(j=0 j<3 j++)
{
if(strcmp(leader_name,leader[j].name)==0)
leader[j].count++ //所选人与候选人的姓名相同,则该候选人的票数加1;
}
}
cout<<endl
double round
for(i=0 i<3 i++)
{
round=leader[i].count/10
cout<<leader[i].name<<":"<<"得票数:"<<leader[i].count<<"得票率:"<<round<<endl
}
return 0
}
using namespace std
struct Person//声明结构体类型Person;
{
char name[20]
int count
}
int main()
{
Person leader[3]={"aaa",0,"bbb",0,"ccc",0}
//定义Person类型的数组,内容为当前候选人的姓名及得票数;
char leader_name[20] //leader_name为投票人所选的人姓名;
int i,j
for(i=0 i<10 i++)
{
cin>>leader_name //先后输入十张票上所选的人的姓名;
for(j=0 j<3 j++)
{
if(strcmp(leader_name,leader[j].name)==0)
leader[j].count++ //所选人与候选人的姓名相同,则该候选人的票数加1;
}
}
cout<<endl
double round
for(i=0 i<3 i++)
{
round=leader[i].count/10
cout<<leader[i].name<<":"<<"得票数:"<<leader[i].count<<"得票率:"<<round<<endl
}
return 0
}
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Debug\BuildLog.htm
.....\choose.exe.embed.manifest
.....\choose.exe.embed.manifest.res
.....\choose.exe.intermediate.manifest
.....\choose.pch
.....\choose.pdb
.....\leader.obj
.....\mt.dep
.....\vc60.idb
.....\vc60.pdb
.....\vc90.idb
.....\vc90.pdb
choose.dsp
choose.dsw
choose.ncb
choose.sln
choose.vcproj
choose.vcproj.WIN-74UE0280MC2.Administrator.user
leader.cpp
Debug
.....\choose.exe.embed.manifest
.....\choose.exe.embed.manifest.res
.....\choose.exe.intermediate.manifest
.....\choose.pch
.....\choose.pdb
.....\leader.obj
.....\mt.dep
.....\vc60.idb
.....\vc60.pdb
.....\vc90.idb
.....\vc90.pdb
choose.dsp
choose.dsw
choose.ncb
choose.sln
choose.vcproj
choose.vcproj.WIN-74UE0280MC2.Administrator.user
leader.cpp
Debug