㈠ c语言编程问题
voiddel(char*s,intn,intlen)
{char*p,*q;
for(p=s;*p;p++);
if(n<0||n+len>p-s){printf("error");return0;}
p=s+n;
q=p+len;
for(;*p=*q;);
}
㈡ c语言编程作业 函数strdel,求指导!!
请问接口是什么
函数的原型是什么
#include <stdio.h>
void strdel(char*s,char del)
{
int i,j;
for(i=0,j=0;s[i];i++)
{
if(s[i]!=del)
s[j++] = s[i];
}
s[j] = 0;
}
int main()
{
char s[1000];
char del;
while(gets(s)!=NULL)
{
scanf("%c",&del);
strdel(s,del);
printf("%s\n",s);
}
}
㈢ 【C语言编程】写一个函数del,删除动态链表中指定的结点
#include <stdio.h>
#include <malloc.h>
#include <conio.h>
typedef struct node //定义节点
{
int value;
struct node* next;
}note;
note* head = NULL;
void del (note** head, int k)//删除链表
{
note* pp;
note* pt;
note* pq;
pp = *head;
if ((*head)->value == k)//如果头结点的值等于k,删除头结点
{
*head = (*head)->next;
return;
}
while(pp->value != k)
{
pt = pp;
pq = pp->next;
pp = pq;
}
pt->next = pp->next;//删除结点
}
void insert(note** head, int q)//建立链表
{
note* pp;
note* pt;
note* p = (note*)malloc(sizeof(note));
p->value = q;
p->next = NULL;
pp = *head;
if (*head==NULL)
{
*head=p;
return;
}
while(pp->next!=NULL)
{
pt = pp->next;
pp = pt;
}
pp->next = p;
}
void print(note* head)//打印链表
{
note* pp;
while(head!=NULL)
{
printf("%d ", head->value);
pp = head->next;
head = pp;
}
}
int main()
{
int i;
int n,k,value;
scanf("%d %d",&n, &k);
for(i=0; i<n; i++)
{
scanf("%d", &value);
insert(&head, value); //把head的地址传过去
}
del(&head, k);
print(head);
getch();//随意按个键退出界面
return 0;
}
㈣ C语言问题 实现在字符串的内部删除字符串的函数del。
#include<stdio.h>
voiddel(char*s,intn,intlen)
{char*p;
s+=n;
for(p=s+len;*s++=*p++;);
}
intmain()
{chars[]="apple";
if(s==NULL||n<0)
{printf("error");
return0;
}
del(s,2,2);
puts(s);
return0;
}
㈤ C语言编程 编写一个函数delchar(char s[],char ch) 将数组s存放的字符串中
voiddelchar(chars[],charch)
{
char*pre=s;
char*aft=s;
while(*aft)
{
if(*aft!=ch){
*pre=*aft;
++pre;
++aft;
}else{
++aft;
}
}
*pre='