') {if(*s==c) s=s+1 else *a++=*s+"og:type" content="webpage">') {if(*s==c) s=s+1 else *a++=*s+" /> ') {if(*s==c) s=s+1 else *a++=*s+"> 编写一个程序实现在一个一维数组中,删除指定的数据,删除数据用函数实现。_sql_内存溢出

阅读 17

编写一个程序实现在一个一维数组中,删除指定的数据,删除数据用函数实现。,第1张

#include<stdio.h>

char fun(char *s,char c,char *a)

{while(*s!='\0')

{if(*s==c)

s=s+1

else

*a++=*s++}

*++a='\0'

}

main()

{char s[80],a[80]

char c

gets(s)

scanf("%c",&c)

fun(s,c,a)

puts(a)

getch()

}其中fun函数为删除数组中的数据的函数。但请注意,我定义了字符数组来输入原始数据,gets()能输入逗号

,puts()也能输出逗号,所以你在输入那些初值时,用空格吧,别用逗号,不然输出时,就会连逗号也输出的!呵呵~~希望对你有用~~

这是pascal的

for i:=1 to n do

if a[i]=5 then a[i]=maxint

(过一遍 ,把5元素的标出来,maxint可换为一些特殊的数据)

for i:=2 to n do if a[i]<>maxint then (本身不是maxint前移

)

while a[i-1]=maxint then

begin

a[i-1]:=a[i] a[i]:=maxint(连续 *** 作

,只要前面的是标出的就前移,

end 直到前面的不是maxint)

(后面非5的前移)

(下次使用的时候到maxint不 *** 作)

总的说就可以实现了


初学 有些烦 但也可以不前移, *** 作是若是maxint不 *** 作

欢迎分享,转载请注明来源:

内存溢出

原文地址:

https://outofmemory.cn/sjk/6659494.html
函数
(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
数据库图书管理系统代码
上一篇
2023-03-26
数据库脱机和分离的区别
2023-03-26

发表评论
请登录后评论... 登录
提交

    评论列表(0条)
保存
{label} {label}