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

WA了两次,大伙说的我都注意了,为什么还错呢?求解释!!!

Posted by 771385494 at 2011-11-27 20:28:05 on Problem 2159
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	char message[101],str1[101],str2[101];
	while(scanf("%s",str1) != EOF){
		scanf("%s",message);
		int map[101] = {0},i,j,count = 0;
		int length = strlen(message);
		if(length != strlen(str1)){
			cout << "NO\n";
			return 0;
		}
		for(i = 0;i < length;i++){
			if(message[i] < 'Z')
				str2[i] = (char)(message[i] + 1);
			else
				str2[i] = 'A';
		}
		for(i = 0;i < length;i++)
			for(j = 0;j < length;j++){
				if(str2[i] == str1[j]){
					map[count] = j;
					str1[j] = '0';
					count++;
					break;
				}
			}
		sort(map,map + length);
		for(i = 1;i < length;i++)
			if(map[i] == map[i - 1])
				break;
		if(i == length)
			cout << "YES\n";
		else{
			cout << "NO\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