1326.txt

来自「北大ACM题目例程 详细的解答过程 程序实现 算法分析」· 文本 代码 · 共 44 行

TXT
44 行
字号


//////////////////////////////////////////////////
//Mileage Bank
//
//

#include"stdio.h"

int main()
{
	char city1[100], city2[100], type;
	int total, distance;
	
	while( 1 )
	{
		total = 0;
	
		while( 1 )
		{
			scanf( "%s", city1 );
			
			if( ( city1[0] == '0' || city1[0] == '#' ) && city1[1] == '\0' )
				break;
			
			scanf( "%s %d %c", city2, &distance, &type );
		
			switch ( type )
			{
				case 'F' : total += distance * 2; break;
				case 'B' : total += distance + ( distance + 1 ) / 2; break;
				default  : total += ( distance < 500 ) ? 500 : distance; break;
			}	
		}
		
		if( city1[0] == '#' ) break;
		printf( "%d\n", total );
	}

	return 0;

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?