标题:请兄台们注意发贴时程序的结构!范例!
取消只看楼主
论坛
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:1372
专家分:0
注 册:2006-3-27
 问题点数:0 回复次数:1 
请兄台们注意发贴时程序的结构!范例!

#include <stdio.h>
#include <conio.h>
#include <string.h>

const int SIZE = 10;

int main(void)
{
void Sort(char *stra[]);

char *stra[SIZE] = {"fan", "song", "zhang", "zhao", "wang",
"li", "yin", "shu", "tian", "wei"};
int ia, ipass;

Sort(stra);

for (ia = 0; ia < SIZE; ia++)
{
printf("%s\n", stra[ia]);
}

getch();
return 0;
}

void Sort(char *stra[])
{
int ib, ipass;
char strb[10];

for (ipass = 1; ipass < SIZE; ipass++)
{
for (ib = 0; ib < SIZE - 1; ib++)
{
if (strcmp(stra[ib], stra[ib + 1]) > 0)
{
strcpy(strb, stra[ib]);
strcpy(stra[ib], stra[ib + 1]);
strcpy(stra[ib + 1], strb);
}
}
}
}











搜索更多相关主题的帖子: 范例 结构 
2006-04-29 19:05
论坛
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:1372
专家分:0
注 册:2006-3-27
得分:0 
忘了说了,上面程序是错的

日出东方,唯我不败! 做任何东西都是耐得住寂寞,任何一个行业要有十年以上的积累才能成为专家
2006-04-29 19:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-61175-1-1.html




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

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