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

题目内容 (请给出正确答案)
以下程序段的输出结果为()。charastr[5]="1234";char*pstr=astr;printf("%c",pstr[1]-'0');

A.ASCII码值为2的字符

B.ASCII码值为1的字符

C.2

D.1


参考答案

更多 “ 以下程序段的输出结果为()。charastr[5]="1234";char*pstr=astr;printf("%c",pstr[1]-'0'); A.ASCII码值为2的字符B.ASCII码值为1的字符C.2D.1 ” 相关考题
考题 下列给定程序中,函数fun()的功能是:用冒泡法对6个字符串按由小到大的顺序进行排序。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.试题程序:include <conio.h>include <stdio.h>define MAXLINE 20/*************found**************/fun(char *pstr[6]){int i, j;char *p;for(i=0;i<5;i++){for(j=i+l;j<6;j++)/*************found**************/{ if(strcmp(*(pstr+i),pstr+j)>0){p=*(pstr+i);/*************found**************/* (pstr+i) -pstr+j;* (pstr+j)=p;}}}}main ( ){ int i;char *pstr[6],str[6][MAXLINE];clrscr();for(i=0;i<6;i++) pstr[i]=str[i];printf("\nEnter 6 string(1 string at eachline):\n ");for(i=0;i<6;i++) scanf("%s",pstr[i]);fun(pstr);printf("The strings after sorting:\n ");for(i=0;i<6;i++) printf("%s\n ",pstr[i]);}

考题 试题二(共 15 分)阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。[说明]下面的程序按照以下规则输出给定名词的复数形式:a. 若名词以“y”结尾,则删除 y 并添加“ies” ;b. 若名词以“s” 、 “ch”或“sh”结尾,则添加“es” ;c. 其他所有情况,直接添加“s” 。[C 程序]#include stdio.h#include string.hchar *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");}

考题 设有说明语句:intx=1,y=3,z=5;则下面表达式中值为0的是()。 A、xB、charstr[80];str=”abcdefg”;C、char*pstr=”abcdefg”D、char*pstr=NULL;pstr=”abcdefg”;

考题 阅读以下说明和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");}

考题 下列给定程序中,函数fun()的功能是:用冒泡法对6个字符串按由大到小的顺序进行排序。请改正程序中的错误,使它能得到正确结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio.h>include <stdio.h>define MAXLINE 20void fun(char *pstr[6]){int i,j;char *p;for(i=0;i<5;i++)for(j=i+1;j<6;j++)/*************found*************/if(strcmp((pstr+i),(pstr+j))<0){p=*(pstr+i);*(pstr+i)=*(pstr+j);/*************found*************/*(pstr+j)=*p;}}main(){int i;char*pstr[6],str[6][MAXLINE];clrscr();for(i=0;i<6;i++)pstr[i]=str[i];printf("/nEnter 6 string(1 string at each line):\n");for(i=0;i<6;i++)scanf("%s",pstr[i]);fun(pstr);printf("The strings after sorting:\n");for(i=0;i<6;i++)printf("%s\n",pstr[i]);}

考题 下面程序输出的结果是()。includemain(){char *a="1234";fun(a);printf("\n");}fun(cha 下面程序输出的结果是( )。 #include<stdio.h> main() { char *a="1234"; fun(a); printf("\n"); } fun(char *s) { char t; if(*s) { t=*S++;fun(s);} else return; if(t!='\0') putchar(t); }A.1234B.4321C.1324D.4231

考题 阅读以下说明和C程序,将应填入 (n) 处的字句写在对应栏内。 2、【说明】下面的程序按照以下规则输出给定名词的复数形式。 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"); }

考题 以下程序段的输出结果是 int main() { int a=1234; printf("%2dn",a); return 0; }A.1234B.12C.34D.无结果

考题 对于 char *pstr;,以下赋值语句正确的是()。A.*pstr="Hi"B.pstr="Hi"C.*pstr="Hi"D.**pstr="Hi"