摘要: 歌曲管理系统---实现读、写文件中的歌曲信息、浏览、排序、查找、删除歌曲等功能。#include "stdio.h"#include "stdlib.h"#include "malloc.h"#include "string.h"int i=0;struct song /*结构体数组*/{ char writer[20]; char singer[20]; char time[20]; char name[20];}son[100];/*以下为输入函数*/void enter() { int j; char c[2 阅读全文
posted @ 2011-06-29 16:19 新技术 阅读(426) 评论(0) 推荐(0) 编辑
摘要: 功 能: 使用快速排序例程进行排序 用 法: void qsort(void *base, int nelem, int width, int (*fcmp)(const void *,const void *)); 参数:1、待排序数组首地址; 2、数组中待排序元素数量; 3、各元素的占用空间大小; 4、指向函数的指针,用于确定排序的顺序一、比如:对一个长为1000的数组进行排序时,int a[1000]; 那么base应为a,num应为 1000,width应为 sizeof(int),cmp函数随自己的命名。 qsort(a,1000,sizeof(int ),comp); ... 阅读全文
posted @ 2011-06-29 15:16 新技术 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 随机生成100万个数,存储在文件out1.txt中,使用内部排序完成,并重新储存在文件out2.txt中。(一)使用STL中的qsort函数进行操作:#include "stdio.h"#include "string.h"#include "stdlib.h"#include "time.h"int a[1000000];void load(char filename[]) //写文件{ int i; FILE *fp; fp=fopen(filename,"w"); if(fp==NULL) 阅读全文
posted @ 2011-06-29 14:48 新技术 阅读(472) 评论(0) 推荐(0) 编辑