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

菜鸟求救。。。。1007

Posted by Csea at 2006-04-12 16:05:31
#include <iostream>
using namespace std;

struct info
{
    int index;
    int count;
};

int main()
{
    int n,m,i,count,j,v;
    cin >> n; 
    cin >> m;
    
    char a[100][50];
    info io[100],t;
    
    for (i = 0;i < m;i++)
    {
        cin >> a[i];
        
        count = 0;
        for (v = 0; v < n; v++)
          for (j = v+1; j < n; j++)
            if (a[i][v] > a[i][j])
               count++;
               
        io[i].index = i;
        io[i].count = count;
    }
    for (i = 0; i < m;i++)
    {
        v = i;
        for (j = i+1; j < m;j++)
            if (io[v].count > io[j].count)v = j; 
        if (v != i)
        {
              t = io[i];
              io[i] = io[v];
              io[v] = t;
        }
    }
    
    for (i = 0; i < m;i++)
       cout << a[io[i].index] << endl;
    return 0;
}

交上了,结果是WA。看了老半天,不知道错了哪?哪位高手帮忙指点一下?小弟先道声谢谢了。。。
:)

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