zoukankan      html  css  js  c++  java
  • HDU 1228 字符串到数字的转化

    一道水题,练练字符串的输入输出

     1 #include <cstdio>
     2 #include <cstring>
     3 
     4 using namespace std;
     5 char s1[15] , s2[15];
     6 
     7 int get_num(char *s)
     8 {
     9     if(s[0] == 'z') return 0;
    10     else if(s[0] == 'o') return 1;
    11     else if(s[0] == 't' && s[1] == 'w') return 2;
    12     else if(s[0] == 't' && s[1] == 'h') return 3;
    13     else if(s[0] == 'f' && s[1] == 'o') return 4;
    14     else if(s[0] == 'f' && s[1] == 'i') return 5;
    15     else if(s[0] == 's' && s[1] == 'i') return 6;
    16     else if(s[0] == 's' && s[1] == 'e') return 7;
    17     else if(s[0] == 'e') return 8;
    18     else if(s[0] == 'n') return 9;
    19 }
    20 
    21 int main()
    22 {
    23   //  freopen("a.in" , "r" , stdin);
    24     while(1)
    25     {
    26         int n1 = 0;
    27         while(scanf("%s" , s1)){
    28             if(s1[0] == '+') break;
    29             n1 = n1*10+get_num(s1);
    30         }
    31         int n2 = 0;
    32         while(scanf("%s" , s2)){
    33             if(s2[0] == '=') break;
    34             n2 = n2*10+get_num(s2);
    35         }
    36         if(n1 == n2 && n1 == 0)
    37             break;
    38         printf("%d
    " , n1+n2);
    39     }
    40     return 0;
    41 }
  • 相关阅读:
    Lamp环境搭建
    jquery之下拉列表select
    jquery之radio
    php连接postgresql
    ipython的notebook
    python连接postgresql数据库
    django最简单表单入门
    css制作简单下拉菜单
    下拉列表简单操作
    css制作最简单导航栏
  • 原文地址:https://www.cnblogs.com/CSU3901130321/p/4196822.html
Copyright © 2011-2022 走看看