UVA - 10420 List of Conquests 结构体解法

这是一个使用C++解决UVA 10420问题的程序,通过结构体存储征服者的名字和对应的征服次数。程序读取输入,将名字按字典序排序并统计重复项,最后输出每个征服者的名称及其征服次数。
摘要由CSDN通过智能技术生成
#include<cstdio>
#include<cstring>
#include<cstdlib>

struct Conquest {
	char *name;
	int number;
};

Conquest con[3000];

int main() {

	int number;
	char str[200];
	int mark = 0;
	scanf("%d\n", &number);
	char temp[3000][100]	;
	for(int i = 0; i < number; i++) {
	char *temp = (char *)malloc(75);
		memset(temp,'\0',sizeof(temp));
		gets(str);	
		int start = 0;
//		str[strlen(str)] = ' ';
//		for(;1 ; start++) {
//			if(str[start] < 'A' ||  (str[start] >'Z' && str[start] < 'a') || str[start] > 'z') 	
//				continue;
//			else 
//				break;
//		}
//
		int out = 0;
		for(int j = 0; ; j++) {
			if((str[j] >= 'A' && str[j] <= 'Z') || (str[j] >= 'a' && str[j] <= 'z')) {
			temp[start] = str[j];
			start++;
			out = 1;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值