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-10-30 14:01:40 on Problem 1493
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	int n,i,j;
	char str[13][26],ch;
	while(cin >> n && n != 0){
		ch = cin.get();
		for(i = 0;i < n;i++){
			ch = cin.get();
			cin.getline(str[i],25,'\n');
		}
		int count[13] = {0},index1 = 0,index2 = 0,result = 0;
		for(i = 0;i < n;i++){
			for(j = 0;j < 25;j++)
				if(str[i][j] != 'X'){
					index1 = j;
					break;
				}
			if(index1 == 0 || j == 25){
				cout << 0 << endl;
				break;
			}
			else{
				for(j = index1 + 1;j < 26;j++)
					if(str[i][j] == 'X'){
						index2 = j;
						break;
					}
			}		
			count[i] = index2 - index1;
		}
		if(index1 != 0){
			sort(count,count + n);
			for(i = 1;i < n;i++)
				result += count[i] - count[0];
			cout << result << endl;
		}
	}
	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