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 huangiris at 2012-07-05 09:49:08 on Problem 1007
#include <iostream>
#include <string.h>
using namespace std;
void bubb(int data[],char a[][110],int n)
{
    char temp[110];
    int templ=0;
    for(int i=0;i<n-1;i++)
        for(int j=0;j<n-1-i;j++)
            if(data[j]>data[j+1])
            {
                templ=data[j];
                data[j]=data[j+1];
                data[j+1]=templ;
                strcpy(temp,a[j]);
                strcpy(a[j],a[j+1]);
                strcpy(a[j+1],temp);
            }
}
int main()
{
    int n,m;//n列m行
    cin>>n>>m;
    char a[60][110];
    int b[60];
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
   for(int i=0;i<m;i++)
   {
       int count=0;
       for(int j=0;j<n;j++)
       {
           for(int r=j+1;r<n;r++)
           {
               if(a[i][j]>a[i][r])
               count++;
           }
       }
       b[i]=count;
   }
   bubb(b,a,m);
   for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
                {
                    cout<<a[i][j];
                }
            cout<<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