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 tangjiming at 2007-12-05 01:24:34 on Problem 1007
小弟出来炸到  所以编的程序相当之没效率  希望牛人们不要见笑  不过还是想拿出来和大家讨教下  莫非c在输入字符之前如果又输入都必须加个gatchar();????
  还有  我这是最低级的算法了  拿出来当反面教材  大家都是怎么改进的???

#include<stdio.h>
int n[100];
char zu[100][100];
int hang,lie; 
void print(int x)
{
for(int i=0;i<lie;i++)
 printf("%c",zu[x][i]);
 printf("\n");
}
int min()
{
    int  k=0;
     for(int i=0;i<hang;i++)
       if(n[i]<n[k])  k=i;
       n[k]=0xfffff;
    return k;
   }
int find(int hang)
{
    int n=0;
    for(int i=0;i<lie-1;i++)
      for(int j=i;j<lie;j++)
        if(zu[hang][i]>zu[hang][j]) n++;
    return n;
}
int main()
{
    int i,j;
    
    scanf("%d%d",&lie,&hang);getchar();
     for(i=0;i<hang;i++)
    
    {
     for(j=0;j<lie;j++)
      {
        scanf("%c",&zu[i][j]);
      }
    getchar();
    }
    for(i=0;i<hang;i++)
      n[i]=find(i);
    for(i=0;i<hang;i++)
    print(min());
    
    
    }

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