当前位置:网站首页>C语言选举人投票功能
C语言选举人投票功能
2022-06-09 17:01:00 【m0_64365851】
#include <stdio.h>
#include<string.h>
void feng()//封面
{
printf("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*\n");
printf("\t选举人1:徐\n\t选举人2:何\n\t选举人3:张\n");
printf("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*\n") ;
}
void xuan()//选举功能实现
{
char ch[3];
char n[3];
struct student
{
char name[3];
int votes;
} stu[3]={"徐",0,"何",0,"张",0};
printf("是否投票(y/n):");
scanf("%s",ch);
while(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)
{
printf("请输入你要投票的人姓名:");
scanf("%s",n);
if(strcmp(n,stu[0].name)==0)
stu[0].votes++;
if(strcmp(n,stu[1].name)==0)
stu[1].votes++;
if(strcmp(n,stu[2].name)==0)
stu[2].votes++;
printf("是否继续投票(y/n):");
scanf("%s",ch);
}
printf("\t选举结束\n") ;
printf("\t是否统计票数(y/n):");
scanf("%s",ch);
if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)
printf("\t徐共获%d票\n\t何共获%d票\n\t张共获%d票",stu[0].votes,stu[1].votes,stu[2].votes);
}
int main(int argc, char *argv[])
{
feng();
xuan();
return 0;
}
边栏推荐
- Memory concept
- [East China Normal University] information sharing for the first and second examinations
- [typecho]sql编写中的一些问题
- 论文阅读《Robust Odometry Estimation for RGB-D Cameras》
- go-zero 微服务实战系列(二、服务拆分)
- ELK 不香了!我用 Graylog,轻量多了....
- R 安装/更新 package 报错:failed to lock directory ‘/home/anaconda3/envs/R4.1.2/lib/R/library’
- Virtual storage mechanism
- 可以用来nlp任务评估的计算方法(语意相近计算)
- 经常弹出:VSCode尝试在目标目录创建文件时发生一个错误 重试 跳过这个文件 关闭安装程序
猜你喜欢

Unity-获取XML文件的内容信息

Leetcode 1957. 删除字符使字符串变好(可以,一次过)

14届数独-真题标准数独-Day 6-20220121(补)

La seconde guerre mondiale a été piégée dans ces 4 points d'erreur, un an de plus pour rien!

Scientific research practice | the visualization and visual analysis laboratory of Peking University enrolls summer interns and graduate students

Word tutorial, how to change line spacing in word?
![[East China Normal University] information sharing for the first and second examinations](/img/f9/68b5b5ce21f4f851439fa061b477c9.jpg)
[East China Normal University] information sharing for the first and second examinations

pyepics CA -- 3

常用数的集合

科研实习 | 北京大学可视化与可视分析实验室招收暑期实习生和推免研究生
随机推荐
Oracle分页
一款高颜值开源知识管理工具
杭州期货开户,上哪里开户安全可靠?
Question d: Ma Zori
Swagger登录地址(首次登录可能会报错)
14届数独-真题标准数独-Day 5-20220120
SDN environment usage and openflow protocol flow analysis of software defined network experiment
存储器概念
Why do SQL statements use indexes but still slow queries?
使用tesseract识别图片中的文字
DZ插件-免费DZ插件大全汇集所有插件功能
Manjaro kconsole开启半透明
经常弹出:VSCode尝试在目标目录创建文件时发生一个错误 重试 跳过这个文件 关闭安装程序
pycharm安装scrapy库时出现报错Error occurred when installing package ‘Scrapy‘
DAY6-T1345&T39 -2022-01-21-非自己作答
How to find and delete duplicate documents in endnote
Elk is not fragrant! I use grayog, which is much lighter
pta7-6悄悄关注
问题 D: 马走日
pyepics Device:PVs的集合