c语言 数字分组! 急急急!!!

[复制链接]
查看11 | 回复2 | 2008-11-16 17:03:14 | 显示全部楼层 |阅读模式
有一组不重复的数字,把数值连续的数字分组
如:1 7 3 9 10 6 2
第一组:1 2 3 第二组:6 7第三组:9 10
原始数据放在source[10],结果存于result[10][10]中,请具体实现!

回复

使用道具 举报

千问 | 2008-11-16 17:03:14 | 显示全部楼层
先排序,再找断带。//---------------------------------------------------------------------------#include #include int cmp(const void *a,const void *b){ return *(int *)a-*(int *)b;}int main(void){ int source[10]={1,7,3,9,10,6,2,13,14,15},result[10][10]={0}; int i=1,j=0,k=0; qsort(source,...
回复

使用道具 举报

千问 | 2008-11-16 17:03:14 | 显示全部楼层
先排序 排后成123 6 7 910 然后遍历,若比上一个数大一,就加入当前行 否则加入另一行#include void selectsort(int a[],int count){int min;for(int i=0;i<count;i++) {
min=i;
for(int ...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行