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

危急!!!危急!!!危急!!!,那为大侠可以帮忙看一下,结果正确,怎么会是WRONG ANSWER?

Posted by xueer at 2005-10-05 08:22:48 on Problem 1007
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main(int argc, char *argv[])
{
  char a[100][100];
  int c[100][2],i,j,k,m,n,t;
  cin>>n>>m;
  for(i=0;i<m;i++)
  for(j=0;j<n;j++)
  cin>>a[i][j];
   for(i=0;i<m;i++)
   {c[i][0]=0;
   for(j=0;j<n;j++)
   for(k=j+1;k<n;k++)
   if(a[i][j]>a[i][k])  c[i][0]+=1;
   c[i][1]=i;
   }

for(i=1;i<m;i++)
for(j=0;j<m-i;j++)
if(c[j][0]>c[j+1][0]) {t=c[j][0];c[j][0]=c[j+1][0];c[j+1][0]=t;
t=c[j][1];c[j][1]=c[j+1][1];c[j+1][1]=t;
}  

for(i=0;i<m;i++)
{k=c[i][1];

puts(a[k]);
k=0;
}
  system("PAUSE");	
  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