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

Re:我感觉知道题用c写很简单,但是不知道有很多人用其他语言写的那么复杂,我的,16Ms 576B

Posted by mingjiereng at 2010-05-21 18:07:18 on Problem 1007
In Reply To:我感觉知道题用c写很简单,但是不知道有很多人用其他语言写的那么复杂,我的,16Ms 576B Posted by:rishiabc at 2010-05-19 14:25:33
> #include<stdio.h>
> #include<string.h>
> int main()
> {
>  int m,n,str[108]={0},i,j,s=0,k,temp;
>  char string[108][100],ss[58];
>  scanf("%d %d",&n,&m);
>  for(k=0;k<m;k++)
>  {
>   scanf("%s",string[k]);
>   for(i=0;i<n-1;i++)
>    for(j=i+1;j<n;j++)
>    {
>     if(string[k][i]>string[k][j])
>     str[k]++;
> }
> }
> for(j=0;j<m-1;j++)
> for(i=0;i<m-1-j;i++)
> if(str[i]>str[i+1])
> {
>  temp=str[i];
>  str[i]=str[i+1];
>  str[i+1]=temp;
>  strcpy(ss,string[i]);
>  strcpy(string[i],string[i+1]);
>  strcpy(string[i+1],ss);
> }
> for(i=0;i<m;i++)
> printf("%s\n",string[i],str[i]);
> 
> 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