首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

(poj1.1.3)1326(直说式模拟)

2013-10-06 
(poj1.1.3)1326(直叙式模拟)/* * 1326_1.cpp * *Created on: 2013年10月6日 *Author: Administrator */#in

(poj1.1.3)1326(直叙式模拟)

/* * 1326_1.cpp * *  Created on: 2013年10月6日 *      Author: Administrator */#include <iostream>#include <cstdio>using namespace std;int main(){    char begin[20];    char end[20];    char number[20];int length;int sum = 0;while(scanf("%s",&begin) != EOF){if(!strcmp(begin,"0")){printf("%d\n",sum);sum = 0;continue;}if(!strcmp(begin,"#")){break;}    scanf("%s %d %s",&end,&length,&number);if(!strcmp(number,"F")){sum += (length*2);}else if(!strcmp(number,"B")){sum += ((length%2 == 0)?(length + length/2):(length + length/2 + 1));}else{if(length < 500){sum += 500;}else{sum += length;}}}}

热点排行