更多"以下程序段用以统计链表中元素的个数。其中first指向链表第一个结点,"的相关试题:
[填空题]以下程序段的功能是统计链表中结点的个数,其中first为指向第一个结点的指针(链表带头结点)。请在下划线内填入正确内容。
struct link
{ char data;
struct link*next;};
…
struct link*p,*first;
int c=0;
p=first;
while( 【19】 )
{ c++;
p= 【20】 ;}
[填空题]以下程序段用于构成一个简单的单向链表。请填空。
struet STRU
int x,y;
float rate;
【14】 p;
a,b;
a.x=0; a.y=0;a.rate=0;a.p=&b;
b.x=0;b.y=0;b.rate=0;b.p=NULL;
[单项选择] First Impressions Count
Traditionally uniforms were-and for some industries still are-manufactured to protect the worker. When they were first designed, it is also likely that all uniforms made symbolic sense-those for the military, for example, were originally intended to impress and even terrify the enemy; other uniforms denoted a hierarchy-chefs wore white because they worked with flour, but the main chef wore a black hat to show he supervised.
The last 30 years, however, have seen an increasing emphasis on their role in projecting the image of an organization and in uniting the workforce into a homogeneous unit-particularly in ’’customer facing’’ industries, and especially in financial services and retailing. From uniforms and workwear has emerged ’’ corporate clothing’’. "The people you employ are your ambassadors," says Peter Griffin, managing director of a major retailer in the UK. "What they say, how they look, and how they behave is terrib
A. Y
B. N
C. NG
[单项选择]以下正确的程序段是
A. char str1[]="12345",str2[]="abcdef";
B. char str[10],*st="abcde";strcat(str,st);
C. charstr[10]=" "。*st="abcde";strcat(str,st);
D. char*st1="12345",*st2="abcde";strcat(st1,st2);
[单项选择]设变量已正确定义,以下不能统计出一行中输入字符个数(不包含回车符)的程序段是()
A. n=0; while(( ch=getchar())!='/n') n++;
B. n=0; while( getchar()! ='/n') n++;
C. for( n=0; getehar()!='/n'; n++);
D. n=0; for( ch=getchar(); ch!='/n'; n++);
[填空题]
以下程序创建-个链表并实现数据统计功能。函数WORD *create(char a[][20],int n)创建-个包含n个结点的单向链表,结点数据来自a指向的数组中存储的n个单词(字符串)。函数void count(WORD *h)统计h指向的单向链表中不同单词各自出现的次数,将统计结果保存到局部数组c中并输出。程序运行时输出结果为"red:1 green:2 blue:3"试完善程序以达到要求的功能。
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
typedef struct w
{char word[20];
struct w *next:
}WORD;
WORD *create(char a[][20],int n)
{WORD *p1,*p2,*h=0;int i;
for(i=0;i {p1=(WORD *)malloc(sizeof(WORD));
strcpy((),a[i]);
if(h==O)
h=p2=p1:
else
{p2->next=p1;p2=pl;}
}
p2->next=();
return h;
}
void count(WORD *h)
{ struct
{char word[20];
int num;
}c[6]={0};
int m=0,i;
while(h)
{if(m==O)
{strcpy(c[0].word,h->word);
c[0].num=1;m++;
}
else
{for(i=O;i if(strcmp(c[i].word,h->word)==0)
{ () ;
break;
}
[单项选择]以下程序段完全正确的是
A. int *p; scanf("%d", &p);
B. int *p; scanf("%d", p);
C. int k,*p=&k;scanf("%d",p);
D. int k,*p; *p= &k; scanf("%d",p);