| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 961 人关注过本帖
标题:c语言初级编程问题
只看楼主 加入收藏
zz199200
Rank: 1
等 级:新手上路
帖 子:18
专家分:2
注 册:2011-11-26
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:6 
c语言初级编程问题
problem
These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fairly difficulty to do such a thing. Of course, I got it after many waking nights.
Give you some integers, your task is to sort these number ascending (升序).
You should know how easy the problem is now!
Good luck!

Input
Input contains multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains an integer N (1<=N<=1000 the number of integers to be sorted) and then N integers follow in the same line.
It is guarantied that all integers are in the range of 32-int.

Output
For each case, print the sorting result, and one line one case.

Sample Input
2
3 2 1 3
9 1 4 7 2 5 8 3 6 9

Sample Output
1 2 3
1 2 3 4 5 6 7 8 9
搜索更多相关主题的帖子: single c语言 difficulty multiple question 
2011-11-26 19:40
cqm9266
Rank: 3Rank: 3
来 自:福建
等 级:论坛游侠
帖 子:174
专家分:186
注 册:2011-10-28
收藏
得分:1 
为什么你要打英文
》?

没病的人说有病的人有病,有病的人说没病的人有病。到底是谁有病?
2011-11-26 22:48
luchar
Rank: 9Rank: 9Rank: 9
来 自:南京
等 级:蜘蛛侠
帖 子:279
专家分:1263
注 册:2011-11-3
收藏
得分:1 
回复 2楼 cqm9266
因为那题本身就是这样的,人家直接复制粘贴的
2011-11-27 01:56
于祥
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:5
帖 子:1047
专家分:4132
注 册:2011-4-24
收藏
得分:1 
我去

最基础的往往是你最容易忽略的!
2011-11-27 09:37
cosdos
Rank: 9Rank: 9Rank: 9
来 自:ShangHai
等 级:蜘蛛侠
威 望:6
帖 子:2109
专家分:1385
注 册:2007-6-19
收藏
得分:1 
用快速排序

—>〉Sun〈<—
2011-11-27 10:46
心灵百合
Rank: 5Rank: 5
等 级:职业侠客
帖 子:215
专家分:367
注 册:2011-3-30
收藏
得分:1 
先翻译成中文吧,看不懂
2011-11-27 11:14
lz1091914999
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:四川
等 级:贵宾
威 望:37
帖 子:2011
专家分:5959
注 册:2010-11-1
收藏
得分:15 
程序代码:
#include <stdio.h>
#include <stdlib.h>
#define N 1000u

int compare(const void *p1, const void *p2)
{
   return *(int *)p1 - *(int *)p2;
}

int contains(int *buffer, int value, int bufferSize)
{
   int i;

   for (i = 0; i < bufferSize; ++i)
      if (buffer[i] == value)
         return 1;
   return 0;
}

int main(void)
{
   int T, integers[N], i = 0, j, k, ch, temp;

   scanf("%d", &T);
   getchar();  // Skip the '\n'
   while (i++ < T) {
      // If the character ch is not '\n' then put it back in stdin, else break.
      for (j = 0; (ch = getchar()) != '\n' ? ungetc(ch, stdin) : 0;) {
         scanf("%d", &temp);
         // If integers not contains the next input then adding to the integers.
         if (!contains(integers, temp, j))
            integers[j++] = temp;
      }
      qsort(integers, j, sizeof(int), compare);
      for (k = 0; k < j; ++k)
         printf("%d ", integers[k]);
      printf("\n");
   }
}
图片附件: 游客没有浏览图片的权限,请 登录注册



[ 本帖最后由 lz1091914999 于 2011-11-27 13:15 编辑 ]

My life is brilliant
2011-11-27 13:14
快速回复:c语言初级编程问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019374 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved