为什么这段程序运行后没有输出?
  • 板块学术版
  • 楼主Cutest_Junior
  • 当前回复17
  • 已保存回复17
  • 发布时间2020/7/25 10:15
  • 上次更新2023/11/6 22:20:57
查看原帖
为什么这段程序运行后没有输出?
246014
Cutest_Junior楼主2020/7/25 10:15

代码:

# include <iostream>
# include <map>
# include <cstdio>

using namespace std ;

int read ( )
{
	int a ;
	char c = getchar ( ) ;
	
	while ( c < '0' || c > '9' )
	{
		c = getchar ( ) ;
	}
	
	while ( c >= '0' && c <= '9' )
	{
		a = a * 10 + c - '0' ;
		c = getchar ( ) ;
	}
	
	return a ;
}

int pay ( int t )
{
	if ( t <= 43200 )
	{
		t /= 1800 ;
		return t * 5 ;
	}
	else
	{
		t /= 3600 ;
		return t * 15 ;
	}
}

map < int , int > time ;

int main ( )
{
	ios :: sync_with_stdio ( 0 ) ;
	
	int n = read ( ) ;
	
	for ( int u , t , p ; cin >> u >> t >> p ; )
	{
		if ( p )
		{
			cout << "You need to pay " << pay ( t - time [ u ] ) 
			<< " yuan. Good luck.\n" ;
			
			time . erase ( u ) ; 
		}
		else
		{
			if ( time . size ( ) == n )
			{
				cout << "Sorry, Jinlanwan is full.\n" ;
			}
			else
			{
				cout << "Welcome to Jinlanwan.\n" ;
				
				time [ u ] = t ;
			}
		}
	}
	
	return 0 ;
}

输入:

1
1 1 0
1 2 1
1 3 0
2 4 0
1 1900 1
1 1901 0
1 46000 1

输出

Welcome to Jinlanwan.
You need to pay 0 yuan. Good luck.
Welcome to Jinlanwan.
Sorry, Jinlanwan is full.
You need to pay 5 yuan. Good luck.
Welcome to Jinlanwan.
You need to pay 180 yuan. Good luck.

在本地可以通过,但在洛谷上就什么都不输出。

2020/7/25 10:15
加载中...