HDU 1228 A + B 字符串水题

HDU 1228 A + B 字符串水题

总之就是很水。。。。
#include <stdio.h>
#include <string.h>

char num[55][55];
int sum;
int len[2];
int n;
int a;
int t;
int shu[2][55];
int main()
{
    while (1)
    {
	a = 0;
	t = 0;
	sum = 0;
	memset(shu, 0, sizeof(shu));
	memset(len, 0, sizeof(len));
	memset(num, 0, sizeof(num));
	while (scanf("%s", num[t]) != EOF && strcmp(num[t], "=") != 0)
	{
	    if (strcmp (num[t], "+") == 0)
	    {
		a ++;
	    }
	    else
	    {

		if (strcmp (num[t], "zero") == 0)
		{
		    shu[a][len[a]] = 0;	    
		}
		if (strcmp (num[t], "one") == 0)
		{
		    shu[a][len[a]] = 1;	    
		}
		if (strcmp (num[t], "two") == 0)
		{
		    shu[a][len[a]] = 2;	    
		}
			
		if (strcmp (num[t], "three") == 0)
		{
		    shu[a][len[a]] = 3;	    
		}
		if (strcmp (num[t], "four") == 0)
		{
		    shu[a][len[a]] = 4;	    
		}
		if (strcmp (num[t], "five") == 0)
		{
		    shu[a][len[a]] = 5;	    
		}
		if (strcmp (num[t], "six") == 0)
		{
		    shu[a][len[a]] = 6;	    
		}
		if (strcmp (num[t], "seven") == 0)
		{
		    shu[a][len[a]] = 7;	    
		}
		if (strcmp (num[t], "eight") == 0)
		{
		    shu[a][len[a]] = 8;	    
		}
		if (strcmp (num[t], "nine") == 0)
		{
		    shu[a][len[a]] = 9;	    
		} 
		len[a] ++;
	    }
	}
	n = 0;
	for (int i = 0; i < len[0]; i ++)
	{
	    n = n * 10 + shu[0][i];
	}
	sum += n;
	n = 0;
	for (int i = 0; i < len[1]; i ++)
	{
	    n = n * 10 + shu[1][i];
	}
	sum += n;
	if (sum == 0)
	    break;
	else
	    printf("%d\n", sum);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值