综合实践报告(6)--2 投票系统

用结构体的形式 给 zhou he lu 三个人投票
题目简单  代码如下


#include
using namespace std;
struct per
{
    string name;
    int p;
} a[3]= {"zhou",0,"he",0,"lu",0};
int main()
{
    string s;
    int i;
    for(i=0; i<10; i++)
    {
        cin>>s;
        if(s==a[0].name)
        {
            a[0].p++;
        }
        else if(s==a[1].name)
        {
            a[1].p++;
        }
        else if(s==a[2].name)
        {
            a[2].p++;
        }
        else
        {
            cout<<"你输入的投票对象有误"<

你可能感兴趣的:(153,155,第六次实验报告)