| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
有事WA,需要帮忙找错啊,我是用下标做的,附代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator