[Codeforces Round #151 (Div. 2)]A. Buggy Sorting

地址:http://codeforces.com/contest/246/problem/A

很明显是一个错误的冒泡排序,想输出非减序列,但是大数字沉底后仍然进入了下一次排序

给一个递减序列就能指出这个算法的错误

 1 #include<stdio.h>
 2 
 3 int n;
 4 
 5 int main()
 6 {
 7     int i;
 8     scanf("%d",&n);
 9     for(i=0;i<n;i++)
10     {
11         if(1==n || 2==n) {printf("-1");break;}
12         printf("%d ",n-i);
13     }
14     printf("\n");
15     return 0;
16 }

 

posted @ 2013-01-19 23:24  tjsuhst  阅读(204)  评论(0)    收藏  举报