<span style="font-size:24px;color:#33ccff;">用结构体的形式 给 zhou he lu 三个人投票</span>
<span style="font-size:24px;color:#33ccff;">题目简单 代码如下</span>
<span style="color:#6600cc;">#include<iostream>
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<<"你输入的投票对象有误"<<endl;
i--;
}
}
for(i=0; i<3; i++)
cout<<a[i].p<<endl;
return 0;
}</span>