c语言输入5个数排列后输出,哪里错了呢? - 爱问答

(爱问答)

c语言输入5个数排列后输出,哪里错了呢?

#include <stdio.h>
#define numlen 5
void delay(int *k, int len)
{
int temp, *b, *c;
for(c = k; c < k+len-1; c++)
for (b=c+1; b < k+len; b++)
if (*c >*b )
{
temp = *c;
*c = *b;
*b = temp;
}
}
int main()
{
int a[numlen],*p;
for(p=a; p < a+numlen; p++)
scanf("%d",p);
delay(a, numlen);
for (p=a; p < a+numlen; p++)
printf("%d", *p);
return 0;
}

c语言输入5个数排列后输出,哪里错了呢?


//是输入5个字母还是  5个字符串?看你的程序像是五个字符串啊。

12345678910111213141516171819202122232425262728293031323334   //按照5个字母的理解给你写了一个,有问题追问#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ int i, j; char word[5]; char temp; printf("5 words input:"); for (i = 0; i < 5; i++) {  scanf("%c", &word[i]); } for (i = 0; i < 5; i++) {  for (j = 0; j < 5-i-1;j++)  {   if (word[j]>word[j+1])   {    temp=word[j];    word[j]= word[j+1];     word[j+1]=temp;   }  } } printf("outputting after ordering:"); for (i = 0; i < 5; i++){  printf("%c",word[i]); } getchar(); getchar(); getchar();}  


相关标签:c语言

下一篇:下单接龙小程序怎样操作?

上一篇:Hello.c可执行程序的生成

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?