ZOJ 2971 && HNUOJ 16490 Give Me the Number
来源:互联网 发布:toupview显微图像软件 编辑:程序博客网 时间:2024/06/08 20:13
这题真的不难,WA到死,为什么?看最后注释掉的代码就知道了。
#include <cstdio>#include <cstring>#include <cmath>#include <climits>#include <cstdlib>#include <cassert>#include <algorithm>#include <iostream>#include <string>#include <map>using namespace std;char arr[2117];char mir[50];int chartoint(){ if(strcmp(mir, "zero") == 0){ return 0; } if(strcmp(mir, "one") == 0){ return 1; } if(strcmp(mir, "two") == 0){ return 2; } if(strcmp(mir, "three") == 0){ return 3; } if(strcmp(mir, "four") == 0){ return 4; } if(strcmp(mir, "five") == 0){ return 5; } if(strcmp(mir, "six") == 0){ return 6; } if(strcmp(mir, "seven") == 0){ return 7; } if(strcmp(mir, "eight") == 0){ return 8; } if(strcmp(mir, "nine") == 0){ return 9; } if(strcmp(mir, "ten") == 0){ return 10; } if(strcmp(mir, "eleven") == 0){ return 11; } if(strcmp(mir, "twelve") == 0){ return 12; } if(strcmp(mir, "thirteen") == 0){ return 13; } if(strcmp(mir, "fourteen") == 0){ return 14; } if(strcmp(mir, "fifteen") == 0){ return 15; } if(strcmp(mir, "sixteen") == 0){ return 16; } if(strcmp(mir, "seventeen") == 0){ return 17; } if(strcmp(mir, "eighteen") == 0){ return 18; } if(strcmp(mir, "nineteen") == 0){ return 19; } if(strcmp(mir, "twenty") == 0){ return 20; } if(strcmp(mir, "thirty") == 0){ return 30; } if(strcmp(mir, "forty") == 0){ return 40; } if(strcmp(mir, "fifty") == 0){ return 50; } if(strcmp(mir, "sixty") == 0){ return 60; } if(strcmp(mir, "seventy") == 0){ return 70; } if(strcmp(mir, "eighty") == 0){ return 80; } if(strcmp(mir, "ninety") == 0){ return 90; } if(strcmp(mir, "hundred") == 0){ return 100; } if(strcmp(mir, "thousand") == 0){ return 1000; } if(strcmp(mir, "million") == 0){ return 1000000; } else{ return -1; }}int main(){//#ifndef ONLINE_JUDGE// freopen("input.txt", "r", stdin);//#endif // ONLINE_JUDGE int t; int d, w, len, num, n, i, j, k, flag; int n1, n2, n3; while(scanf("%d", &t) != EOF){ getchar(); while(t--){ n1 = n2 = n3 = d = w = 0; memset(arr, 0, sizeof(arr)); gets(arr);// cout << arr << endl; i = 0; len = strlen(arr);// cout << len << endl; d = 0; flag = 0; n1 = n2 = n3 = 0; while(i < len){// printf("%c\n", arr[i]); k = 0; if(arr[i] != ' '){ memset(mir, 0, sizeof(mir)); k = 0; for(j = i; j < len; j++){ if(arr[j] == ' '){ break; } else{ mir[k++] = arr[j]; } }// puts(mir); i += (k); w = chartoint(); if(w == 1000000 || w == 1000){ if(w == 1000000){ n1 = d; flag = 0; d = 0; } if(w == 1000){ n2 = d; flag = 0; d = 0; }// cout << n1 << " " << n2 << endl; i++; continue; } if(w == -1){ flag = 0; i++; continue; } if(w % 10 == 0){ if(flag == 1){ d *= w; } else{ d += w; } flag = 0; i++; continue; }// cout << w << endl; if(flag == 1){ d *= w; } else if(flag == 0){ d += w; } flag = 1;// printf("flag = %d\n", flag);// cout << d << endl; } i++; }// cout << d << endl; n3 = d;// if(n1 == 0){// if(n2 == 0){// printf("%d\n", n3);// continue;// }// else{// printf("%d,%03d\n", n2, n3);// continue;// }// }// else{// printf("%d", n1);// printf(",");// printf("%03d", n2);// printf(",");// printf("%03d", n3);// printf("\n");// }// getchar(); if(n1 == 0){ if(n2 == 0){ printf("%d\n", n3); } else{ printf("%d%03d\n", n2, n3); } } else{ printf("%d%03d%03d\n", n1, n2, n3); } } }return 0;}
0 0
- ZOJ 2971 && HNUOJ 16490 Give Me the Number
- ZOJ - 2971 Give Me the Number 模拟
- zoj 2971 Give Me the Number
- zoj 2971 Give Me the Number
- ZOJ 2971 Give Me the Number
- ZOJ 2971 Give Me the Number
- ZOJ - 2971 Give Me the Number
- ZOJ 2971 Give Me the Number
- ZOJ 2971 Give Me the Number
- ZOJ 2971Give Me the Number
- [英文转数字]ZOJ 2971 Give Me the Number
- zoj 2971 Give Me the Number (模拟)
- ZOJ 2971-G - Give Me the Number-模拟
- ZOJ 2971 Give Me the Number(模拟)
- ZOJ-2971-Give Me the Number【5th浙江省赛】
- give me the number
- poj 2971 Give Me the Number
- ZOJ2971-Give Me the Number
- ASM详解
- 【转载】Discuz论坛结构
- 棵汛粟重奥蓉晌认疚记猜脑
- OUT_SMS_ONE
- 吭假悼赏碳眯即己舅哨守技
- ZOJ 2971 && HNUOJ 16490 Give Me the Number
- 2014.09.17 周四-jdbc增删改查-javabean、jsp标签
- 单例模式解释
- 油戳吃狡菊仙患桶德人傲钦
- Oracle 12c RAC for AIX7.1(三)系统参数
- ORACLE 参数文件介绍
- Best Time to Buy and Sell Stock
- 谫兴壳湛蠢临霖缕展袄袄男
- CF437div D 贪心+并查集