怎么改成调用函数
怎么将这个函数改成调用函数啊,我改来改去都没值输出。程序代码:
[color=#0000FF]#include<stdio.h> #include <string.h> struct student { char num[20]; char name[20]; }; void main() { struct student stu[10]={ {"201060010","Shen"}, {"201060002","Qian"}, {"201060009","Jiang"}, {"201060003","Sun"}, {"201060005","Wang"}, {"201060006","Zhou"}, {"201060004","Li"}, {"201060008","Zhen"}, {"201060007","Wu"}, {"201060001","Zhao"} }; struct student temp[20]; char x[20]; int i,j; for(i=0;i<10;i++) { printf("%s %s\n",stu[i].num,stu[i].name); } printf("====================================================\n"); for(i=0;i<10;i++) for(j=i+1;j<10;j++) { if(strcmp(stu[i].num,stu[j].num)>0) { temp[i]=stu[i]; stu[i]=stu[j]; stu[j]=temp[i]; } } printf("====================================================\n"); printf("Results:\n\n"); for(i=0;i<10;i++) { printf("%s %s\n",stu[i].num,stu[i].name); } }
[/color]
[ 本帖最后由 宇智波曌 于 2011-5-31 12:48 编辑 ]