41.不会
42.
#include <stdio.h>
#include <stdlib.h>
typedef struct aa
{ int data;
struct aa *next;
} NODE;
NODE *Creatlink(int n, int m)
{ NODE *h=NULL, *p, *s;
int i;
p=(NODE *)malloc(sizeof(NODE));
h=p;
p->next=NULL;
for(i=1; i<=n; i++)
{ s=(NODE *)malloc(sizeof(NODE));
s->data=rand()%m; s->next=p->next;
p->next=s; p=p->next;
}
return h;
}
void outlink(NODE *h)
{ NODE *p;
p=h->next;
printf("\n\nTHE LIST :\n\n HEAD “);
while§
{ printf(”->%d “,p->data);
p=p->next;
}
printf(”\n");
}
void main()
{ NODE *head;
head=Creatlink(8,22);
outlink(head);
}
43.
#include<string.h>
#include<stdio.h>
#define N 80
int fun(char *s)
{
int i,n=0;
for(i=0;s[i]!=’\0’;i++)
if(s[i]!=’ ‘&&(s[i]!=’ ‘||s[i]!=’\0’))
n++;
return(n);
}
void main()
{
FILE *wf;
char line[N];
int num=0;
printf("Enter a string:\n ");
gets(line);
num=fun(line);
printf(“The number of word is:%d\n\n “,num);
wf=fopen(“out.dat”,“w”);
fprintf(wf,”%d”,fun(“a big car”));
fclose(wf);
}
2021-07-06
最新推荐文章于 2022-09-09 22:12:54 发布