网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

阅读以下说明和C程序,将应填入(n)处的字句写在对应栏内。

【说明】

下面的程序按照以下规则输出给定名词的复数形式。

a.若名词以“y”结尾,则删除y并添加“ies”;

b.若名词以“s”、“ch”或“sh”结尾,则添加“es”;

c.其他所有情况,直接添加“s”。

【C程序】

include <stdio.h>

include <string.h>

char*plural(char *word)

{

int n;

char *pstr;

n=strlen(word); /*求给定单词的长度*/

pstr=(char*)malloc(n+3);/*申请给定单词的复数形式存储空间*/

if (!pstr||n<2)

return NULL;

strcpy(pstr,word); /*复制给定单词*/

if ((1))

{

pstr[n-1]='i';pstr[n] ='e';pstr[n+1]='s';(2);

}

else

if(pstr[n-1]=='s'| |pstr[n-1]=='h'&&((3)))

{

pstr[n]='e';pstr[n+1]='s';pstr[n+2]='\0';

}

else

{ pstr[n]='s';pstr[n+1]='\0';)

(4);

}

main()

{ int i; char *ps;

char wc[9][10]=

{"chair","dairy","boss","circus","fly","dog","church","clue","dish");

for(i = 0;i<9; i++) {

ps= (5) ;

printf("%s: %s\n",wc[i],ps); /*输出单词及其复数形式*/

free(ps); /*释放空间*/

}

system("pause");

}


参考答案

更多 “ 阅读以下说明和C程序,将应填入(n)处的字句写在对应栏内。【说明】下面的程序按照以下规则输出给定名词的复数形式。a.若名词以“y”结尾,则删除y并添加“ies”;b.若名词以“s”、“ch”或“sh”结尾,则添加“es”;c.其他所有情况,直接添加“s”。【C程序】include <stdio.h>include <string.h>char*plural(char *word){int n;char *pstr;n=strlen(word); /*求给定单词的长度*/pstr=(char*)malloc(n+3);/*申请给定单词的复数形式存储空间*/if (!pstr||n<2)return NULL;strcpy(pstr,word); /*复制给定单词*/if ((1)){pstr[n-1]='i';pstr[n] ='e';pstr[n+1]='s';(2);}elseif(pstr[n-1]=='s'| |pstr[n-1]=='h'((3))){pstr[n]='e';pstr[n+1]='s';pstr[n+2]='\0';}else{ pstr[n]='s';pstr[n+1]='\0';)(4);}main(){ int i; char *ps;char wc[9][10]={"chair","dairy","boss","circus","fly","dog","church","clue","dish");for(i = 0;i<9; i++) {ps= (5) ;printf("%s: %s\n",wc[i],ps); /*输出单词及其复数形式*/free(ps); /*释放空间*/}system("pause");} ” 相关考题
考题 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【C++程序】include include 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【C++程序】include < stdio. h >include < string. h >define Max 1000class Bank{int index;char date [Max] [10]; // 记录交易日iht amount[Max]; // 记录每次交易金额,以符号区分存钱和取钱int rest[ Max]; // 记录每次交易后余额static iht sum; // 账户累计余额public:Bank( ) {index =0;}void deposit( char d[ ] , int m) //存入交易{strcpy ( date [ index ], d);amount[ index] = m;(1);rest[ index] = sum;index++;}void withdraw (char d[ ], int m) //取出交易{strcpy( date[ index] ,d);(2);(3);rest[ index] = sum;index++;}void display( );};int Bank:: sum = 0;void Bank:: display ( ) //输出流水{int i;printf("日期 存入 取出 余额\n");for (4){printf(" %8s" ,date[i] );if (5)printf(" %6d" , -amount[i] );elseprintf( "%6d ",amount[i] );printf( "% 6d\n" ,rest[i] );} }void main( ){Bank object;object. deposit ( "2006.2.5", 1 00 );object. deposit( "2006.3.2" , 200);object. withdraw( "2006.4.1", 50);object. withdraw( "2006.4.5", 80);object. display ( );}本程序的执行结果如下:日期 存入 取出 余额 2006.2.5 100 1002006.3.2 200 3002006.4.1 50 2502006.4.5 80 170

考题 阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。【说明】已知头指针分别为La和lb的有序单链表,其数据元素都是按值非递减排列。现要归并La和Lb得到单链表Lc,使得Lc中的元素按值非递减排列。程序流程图如下所示:

考题 阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。【说明】以下程序为求行列式X(5,5)的值S。【Visual Basic代码】Private Function col ( byval x ( 5,5 ) as integer ) as longdim fesult as longdim temp as longdim I as integerdim j as integerdim k as imegerresult = 0for I = to 5(1)for j = 1 to 5if I+j>6 thenk= ( 1+j ) mod 5elsek=1endiftemp=temp*x ( k,j )(2)result=(3)(4)(5)End function

考题 阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。[说明]设学生某次考试的成绩按学号顺序逐行存放于某文件中,文件以单行句点“.”为结束符。下面的流程图读取该文件,统计出全部成绩中的最高分max和最低分min。

考题 阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写在对应栏内。【说明】阅读下面几段C++程序回答相应问题。比较下面两段程序的优缺点。①for (i=0; i<N; i++ ){if (condition)//DoSomething…else//DoOtherthing…}②if (condition) {for (i =0; i<N; i++ )//DoSomething}else {for (i=0; i <N; i++ )//DoOtherthing…}

考题 阅读下列程序说明和C程序,将应填入(n)处的字句写在对应栏内。[函数2.1说明]下面程序的功能是计算x和y的最小公倍数。[函数2.1]main(){ int m,n,d,r;seanf("%d %d",m,n);if(m<n) {r=m;m=n;n=r;}(1);while (d%n! =0) (2);printf("%d\n",d);}[函数2.2说明]下述程序接收键盘输入,直到句点“.”时结束。输入的字符被原样输出,但连续的空格输入将转换成一个空格。[函数2.2]include <stdio.h>main(){ char c,preChar='\0';c = getchar();while(c! = '.'){if((3)) putchar(c);else if(preChar! =' ') putchar(c);(4);c=(5);}}

考题 阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。[说明]下面的流程图用于计算一个英文句子中最长单词的长度(即单词中字母个数)MAX。假设该英文句子中只含字母、空格和句点“.”,其中句点表示结尾,空格之间连续的字母串称为单词。[流程图]

考题 ●试题二阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】该程序运行后,输出下面的数字金字塔【程序】includestdio.hmain (){char max,next;int i;for(max=′1′;max=′9′;max++){for(i=1;i=20- (1) ;++i)printf(" ");for(next= (2) ;next= (3) ;next++)printf("%c",next);for(next= (4) ;next= (5) ;next--)printf("%c",next);printf("\n");}}

考题 试题三(共 15 分)阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。

考题 阅读下列说明和?C++代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 阅读下列说明和?Java代码,将应填入?(n)?处的字句写在答题纸的对应栏内。 【说明】 某快餐厅主要制作并出售儿童套餐,一般包括主餐(各类比萨)、饮料和玩具,其餐品种 类可能不同,但其制作过程相同。前台服务员?(Waiter)?调度厨师制作套餐。现采用生成器?(Builder)?模式实现制作过程,得到如图?6-1?所示的类图。