码迷,mamicode.com
首页 > 其他好文 > 详细

E (放代码)

时间:2015-09-06 14:24:04      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

const int N = 1e2 + 10;
const int INF = 0x3f3f3f3f;
string s;

int main(void)	{
	int T;	scanf ("%d", &T);
	getchar ();
	while (T--)	{
		int x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0;
		getline (cin, s);
		int len = s.length ();
		int c = 0;
		if (s[26] == ‘h‘)	{
			int k = 44;
			while (k < len && s[k] >= ‘0‘ && s[k] <= ‘9‘)	x1 = x1 * 10 + s[k++] - ‘0‘;
			bool flag = false;
			for (int i=k; i<len; ++i)	{
				if (s[i] < ‘0‘ || s[i] > ‘9‘)	{
					if (!flag) continue;
					else	break;
				}
				else	{
					flag = true;
					y1 = y1 * 10 + s[i] - ‘0‘;
				}
			}
			if (x1 > y1)	{
				x2 = 0;
			}
			else if (x1 == y1)	{
				x2 = 0;
				if (x2 < y1)	x2++;
			}
			else if (x1 < y1)	{
				x2 = y1 - x1;
				if (x2 < y1)	x2++;
			}

			x3 = y1 + 30 - x1;
			if (x3 > y1)	x3--;
			x3 = min (x3, 30);
			cout << x2 << " " << x3 << endl;
		}
		else	{
			int k = 44;
			while (k < len && s[k] >= ‘0‘ && s[k] <= ‘9‘)	x1 = x1 * 10 + s[k++] - ‘0‘;
			bool flag = false;
			for (int i=k; i<len; ++i)	{
				if (s[i] < ‘0‘ || s[i] > ‘9‘)	{
					if (!flag) continue;
					else	break;
				}
				else	{
					flag = true;
					y1 = y1 * 10 + s[i] - ‘0‘;
				}
			}
			if (x1 > y1)	{
				x2 = 0;
			}
			else if (x1 == y1)	{
				x2 = 0;
			}
			else if (x1 < y1)	{
				x2 = y1 - x1;
			}

			x3 = y1 + 30 - x1;
			x3 = min (x3, 30);
			cout << x2 << " " << x3 << endl;
		}
	}

	return 0;
}

  

E (放代码)

标签:

原文地址:http://www.cnblogs.com/Running-Time/p/4785326.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!