Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

~

Posted by uestc254136 at 2009-04-29 15:26:48 on Problem 2840
字符串获取写下此题最长代码 如下
看了某位同学整数获取很短代码 收获很大
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
	
	//freopen ("in.txt", "r", stdin);
	int n,i,j,m,k;
	char a[1][7];
	scanf("%d" , &n);
	while( n != 0)
	{
		scanf("%s" ,a[0]);
		m = strlen (a[0]);
		if(strcmp("00:00" , a[0]) == 0) printf("12\n");
		else if( m == 4 && a[0][2] =='0'&& a[0][3] == '0')
		{
			k =a[0][0] - 48;
			printf("%d\n" , k + 12);
		}
		else if ( m == 5 && a[0][3] =='0'&& a[0][4] == '0' && (a[0][0] - 48) *10 + a[0][1] - 48 >= 13 )
		{
			k =(a[0][0] - 48) *10 + a[0][1] - 48;
			printf("%d\n" ,  k - 12);
		}
		else if ( m == 5 && a[0][3] =='0'&& a[0][4] == '0'&& (a[0][0] - 48) *10 + a[0][1] - 48 < 13 )
		{
			k =(a[0][0] - 48) *10 + a[0][1] - 48;
			printf("%d\n" ,  k +12);
		}
		else printf("0\n");
		n --;		
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator