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 3013218115 at 2014-08-22 18:54:19 on Problem 1007
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    char str[m][n+5];
    for(int i = 0; i < m; i++)
        cin >> str[i];
    int arr[m+5];
    for(int i = 0; i < m; i++)
    {
        int sum = 0;
        for(int j = 0; j < n - 1; j++)
        {
            int t = j + 1;
            while(t < n)
            {
                if(str[i][j] > str[i][t])
                    sum++;
                t++;
            }
            arr[i] = sum;
        }
    }
    int brr[m+5];
    for(int i = 0; i < m; i++)
    {
        int j = 0;
        int min = arr[j];
        int temp = j;
        for( ; j < m - 1; j++)
        {
            if(arr[j+1] != 100 && min > arr[j+1])
            {
                min = arr[j+1];
                temp = j+1;
            }
        }
        arr[temp] = 100;
        brr[i] = temp;
    }
    for(int i = 0; i < m; i++)
        cout << str[brr[i]] << 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