915xjtu2015_3

本文介绍了一个用于统计m个选举人对n个候选人投票的程序,用户可以输入得票,程序实时更新候选人的得票数,并展示了找出得票最多的候选人。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

编写一个候选人的得票统计程序,设有m个选举人,n个候选人每输入一个得票的候选人名字,要求输出每一个候选人的得票情况。

#include<stdio.h>
#include<string.h>
#define m 10
#define n 3
struct people{
	char name[20];
	int number;
}candidate[n]={"zhangsan",0,"lisi",0,"wangwu",0};
int main(){
	char candidate_name[20];
	printf("请依次输入要投的选举人名字:"); 
	for(int i=0;i<m;i++){
		scanf("%s",&candidate_name);
		for(int j=0;j<n;j++){
			if(strcmp(candidate_name,candidate[j].name)==0){
				candidate[j].number++;
			}
		}
	}
	printf("被选举人得票情况:\n"); 
	for(int k=0;k<n;k++){
		printf("%s得票数:%d\n",candidate[k].name,candidate[k].number);
	}
/**
统计得票最多的人名字	
	int max=candidate[0].number;
	int result=0;
	for(int l=0;l<n;l++){
		if(candidate[l].number>max){
			max=candidate[l].number;
			result=l;			
		}	
	} 
	printf("最终选举人:%s\n",candidate[result].name);
*/
	return 0;
}

Make Error at /opt/ros/noetic/share/catkin/cmake/empy.cmake:30 (message): Unable to find either executable &#39;empy&#39; or Python module &#39;em&#39;... try installing the package &#39;python3-empy&#39; Call Stack (most recent call first): /opt/ros/noetic/share/catkin/cmake/all.cmake:164 (include) /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20 (include) CMakeLists.txt:58 (find_package) -- Configuring incomplete, errors occurred! See also "/home/orangepi/xjtu_copter_2025/build/CMakeFiles/CMakeOutput.log". Invoking "cmake" failed (base) orangepi@orangepi5max:~/xjtu_copter_2025$ ls build devel src (base) orangepi@orangepi5max:~/xjtu_copter_2025$ conda deactivate orangepi@orangepi5max:~/xjtu_copter_2025$ catkin_make Base path: /home/orangepi/xjtu_copter_2025 Source space: /home/orangepi/xjtu_copter_2025/src Build space: /home/orangepi/xjtu_copter_2025/build Devel space: /home/orangepi/xjtu_copter_2025/devel Install space: /home/orangepi/xjtu_copter_2025/install #### #### Running command: "cmake /home/orangepi/xjtu_copter_2025/src -DCATKIN_DEVEL_PREFIX=/home/orangepi/xjtu_copter_2025/devel -DCMAKE_INSTALL_PREFIX=/home/orangepi/xjtu_copter_2025/install -G Unix Makefiles" in "/home/orangepi/xjtu_copter_2025/build" #### -- Using CATKIN_DEVEL_PREFIX: /home/orangepi/xjtu_copter_2025/devel -- Using CMAKE_PREFIX_PATH: /opt/ros/noetic -- This workspace overlays: /opt/ros/noetic -- Using PYTHON_EXECUTABLE: /home/orangepi/miniconda3/bin/python3 -- Using Debian Python package layout -- Could NOT find PY_em (missing: PY_EM) CMake Error at /opt/ros/noetic/share/catkin/cmake/empy.cmake:30 (message): Unable to find either executable &#39;empy&#39; or Python module &#39;em&#39;... try installing the package &#39;python3-empy&#39; Call Stack (most recent call first): /opt/ros/noetic/share/catkin/cmake/all.cmake:164 (include) /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20 (include) CMakeLists.txt:58 (find_package) -- Configuring incomplete, errors occurred! See also "/home/orangepi/xjt
最新发布
07-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值