HDOJ1228

题目:http://acm.hdu.edu.cn/status.php?user=jxufe_JP&pid=1228&status=5

#include<iostream>
#include<cstring>
#include <string>
using namespace std;
int change(char *p1)
{
    if(strcmp(p1,"zero")==0) return 0;
    if(strcmp(p1,"one")==0) return 1;
    if(strcmp(p1,"two")==0) return 2;
    if(strcmp(p1,"three")==0) return 3;
    if(strcmp(p1,"four")==0) return 4;
    if(strcmp(p1,"five")==0) return 5;
    if(strcmp(p1,"six")==0) return 6;
    if(strcmp(p1,"seven")==0) return 7;
    if(strcmp(p1,"eight")==0) return 8;
    if(strcmp(p1,"nine")==0) return 9;

}
int main()
{
    char a[10];
    bool f=0;
    int s1=0,s2=0;
    while(cin>>a)
    {
     if(strcmp(a,"=")==0)
     { f=0;
     if(s1+s2==0)break;
      cout<<s1+s2<<endl;
      s1=s2=0;
      continue;
     }
     if(strcmp(a,"+")==0) {f=1; continue;}//必须要有一个变量来控制是不是符号“+”前面的数还是后面的数
     if(f==0)
       s1=s1*10+change(a);
     else
       s2=s2*10+change(a);

    }
return 0;
}

 

刚用这个微博,不知道怎么弄原来的代码复制过来,哪位大侠教教啊!!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值