本文介绍了在C中对整数列表进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 给定一组整数,如何在C 中编写程序,使用C对这些整数进行排序,给出以下条件 a。不要使用数组 b。不要使用任何比较功能,如if / then 或switch-case c。你只能使用指针 d。你也不能使用任何循环。Given a set of integers, how to write a program in Cto sort these set of integers using C, given the following conditionsa. Do not use arraysb. Do not use any comparison function like if/thenor switch-casec. you can use pointers onlyd. you cannot use any of the loops either.推荐答案 - 从地址删除.spam以通过电子邮件回复。--remove .spam from address to reply by e-mail. 为什么一些大学教授继续设置这样不切实际的作业 问题!?为什么不让学生质疑这些问题的不切实际性? __________________________________________________ _____________________________ 克里斯麦克唐纳博士EMAIL: ch *** @ csse.uwa.edu.au 计算机科学与技术学院软件工程 西澳大利亚大学WWW: http://www.csse.uwa.edu.au/~chris 克劳利,西澳大利亚州,6009 PH:+61 8 6488 2533,传真:+61 8 6488 1089Why do some College professors continue to set such unrealistic homeworkquestions!? Why don''t students question the unrealistic nature of thesequestions?__________________________________________________ _____________________________Dr Chris McDonald EMAIL: ch***@csse.uwa.edu.auSchool of Computer Science & Software EngineeringThe University of Western Australia WWW: http://www.csse.uwa.edu.au/~chrisCrawley, Western Australia, 6009 PH: +61 8 6488 2533, FAX: +61 8 6488 1089 使用qsort() Use qsort() 对,但另一块拼图如何在不使用循环的情况下吸收输入 ? 我想我可以用这样的递归作弊: #include< stdio.h> int read_one_int(FILE * fp,int * i) { int v = fscanf(fp,"%d",i); return(v!= 0&& v!= EOF); } int read_all_ints(FILE * fp,int * v,unsigned num) { 返回num&& read_one_int(fp,v)&& read_all_ints(fp,v + 1,num-1); } - JamesRight, but the other piece of the puzzle is how to absorb the inputwithout using a loop?I suppose I could cheat with recursion like this:#include <stdio.h>int read_one_int(FILE *fp, int *i){int v = fscanf(fp, "%d", i);return (v != 0 && v != EOF);}int read_all_ints(FILE *fp, int *v, unsigned num){return num && read_one_int(fp, v) && read_all_ints(fp, v+1, num-1);}-- James 这篇关于在C中对整数列表进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-29 02:12