填空题下列程序的输出结果是 【6】 。 #define PR(a)printf("%d/t",(int)(a)) #define PRINT(a)PR(a);printf("ok!") main() int i,a=1; for(i=0;i<3;i++) PRINT(a+i); printf("/n");
填空题计算机中存储容量的基本单位是字节,它的英文名称是 【1】。
填空题请补充函数proc(),该函数的功能是:分类统计一个字符串中元音字母和其他字符的个数(不区分大小写)。
例如,输入imnIaeouOWC,结果为:A:1 E:1 1:2 O:2U:1 other:4。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define M 100
void proc(char *str,int bb[])
{
char *p=str;
int i=0;
for(i=0; i<6; i++)
______;
while(*p)
{
switch(*p)
{
case "A":
case "a": bb[0]++; break;
case "E":
case "e": bb[1]++; break;
case "I":
case "i": bb[2]++; break;
case "O":
case "o": bb[3]++; break;
case "U":
case "u": bb[4]++; break;
default: ______;
}
______
}
}
void main()
{
char str[M],ss[6]="AEIOU";
int i;
int bb[6];
system("CLS");
printf("Input a string:/n");
gets(str);
printf("the string is:/n");
puts(str);
proc(str, bb);
for(i=0; i<5; i++)
printf("/n%c: %d", ss[i], bb[i]);
printf("/nother: %d", bb[i]);
}
填空题有以下程序
main( )
{ int t=1,i=5;
for(;i>=0;i--) t*=i;
printf(“%d\n”,t);}
执行后输出结果是【 】。
填空题以下程序的运行结果是______。 #define A 4 #define B(x)A*x/2 main() float c,a=8.0; c=B(a); printf("%f/n",c);
填空题下列给定程序中函数fun的功能是:将s所指字符串中出现的与t1所指字符串相同的子串全部替换为t2所指字符串,所形成的新串放在w所指的数组中。要求t1和t2所指字符串的长度相同。
例如,当s所指字符串中的内容为“abcdabfab”,t1所指子串中的内容为“ab”,t2所指子串中的内容为“99”时,在W所指的数组中的内容应为“99cd99f99”。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void fun(char *s, char *t1, char *t2, char *w)
{
char *p, *r, *a;
strcpy(w, s);
while(*w)
{
p=w; r=t1;
/**********found**********/
while(r)
if(*r==*p){r++; p++;}
else break;
if(*r=="/0")
{
a=w; r=t2;
while(*r)
/**********found**********/
{*a=*r; a++; r++}
w+=strlen(t2);
}
else w++;
}
}
void main()
{
char s[100], t1[100], t2[100], w[100];
system("CLS");
printf("/nPlease enter string S:");
scanf("%s", s);
printf("/nPlease enter substring t1:");
scanf("%s", t1);
printf("/nPlease enter substring t2:");
scanf("%s", t2);
if(strlen(t1)==strlen(t2))
{
fun(s, t1, t2, w);
printf("/ne result is:%s/n", w);
}
else
printf("Error:strlen(t2)/n");
}
填空题执行以下程序的输出结果是{{U}} 【18】 {{/U}}。
#include <stdio.h>
main()
[ int i, n[4]={1};
for(i= 1 ;i<=3 ;i++)
{ n[i]=n[i-1]*2+1; printf("%d",n[i]); }
填空题以下程序运行后的输出结果是 【14】 。 #include <stdio.h> main( ) int a[4] [4]= 1,2,3,4, 5'6'7'8,11'12'13'14,15'16'17'18 ; int i=0,j =0,s =0; while(i ++ <4) if(i ==2 [[ i ==4) continue; j=0; do s+ = a[i][j]; j++; while(j<4); pdnff(" % d'/n" ,s);
填空题下列给定程序中,函数fun()的功能是:实现两个变量值的交换,规定不允许增加语句和表达式。
例如,变量a中的值原为8,b中的值原为3,程序运行后,a中的值为3,b中的值为8。
请改正程序中的错误,使它得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
int fun(int*x,int y)
{
int t;
//****found****
t=x;x=y;
//****found****
return(y);
}
void main()
{
int a=3,b=8;
system("CLS");
printf("%d%d/n",a,b);
b=fun(
printf("%d%d/n",a,b);
}
填空题下列给定程序中,proc()函数的功能是:根据形参n,计算下列公式的值:
t=1-1/2+1/3-1/4+…+(-1)(n+1)/n
例如,若输入6,则应输出0.616667。
请修改程序中的错误,使它能得到正确结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
//****found****
int proc(int n)
{
double t=1.0,j=1.0;
int i;
//****found****
for(i=1;i<n;i++)
{j=-1*j;t+=j/i;}
return t;
}
void main()
{
int n;
system("CLS");
printf("/nPlease enter 1 integer number:");
scanf("%d",
printf("/nThe result is%1f/n",proc(n));}
填空题请补充函数fun(),该函数的功能是:把ASCII码为奇数的字符从字符串str中删除,结果仍然保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。
例如,输入“abcdef”,输出“bdf”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#define N 80
void fun(char s[],int n)
{
int i, j;
j=0;
for(i=0;{{U}} 【1】 {{/U}};i++)
{
if({{U}} 【2】 {{/U}})
s [j++]-s [i];
}
{{U}} 【3】 {{/U}};
}
main ( )
{
int i=0, strlen=0;
char str [N];
clrscr ();
printf ("/nInput a string: /n");
gets (str);
while (str [i] !='/0')
{
strlen++;
i++;
}
fun(str, strlen);
printf("/n*** display string ***/n");
puts (str);
}
填空题下面程序的运行结果是______。 void swap(int *a,int *b) int *tp; t=a;a=b;b=t; main() int x=3,y=5,*p= swap(p,q); printf("%d%d/n",*p,*q);
填空题有以下程序:
int sub(int n) { return(n/10+n%10); }
main()
{int x,y;
scanf("%d",&x);
y=sub(sub(sub(x)));
printf("%d/n",y);
}
若运行时输入1234<回车>,程序的输出结果是{{U}} 【12】 {{/U}}。
填空题请补充main函数,该函数的功能是:把字符串str1中的非空格字符拷贝到字符串str2中。
例如,若sffl=“glad to see you!”,
则str2=“gladtoseeyou!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define N 80
main()
{
static char strl [N] ="glad to see you!";
char str2 IN];
int i=0, j=0;
clrscr ();
printf("/n***** strl*****/n ");
puts (str1);
while (str1 [i] )
{
if({{U}}【1】{{/U}})
str2 [J++] =strl [i];
{{U}}【2】{{/U}};
}
printf("/n***** str2 *****/n ");
for (i=0; i<j; i++)
printf ("%c", str2 [i] );
}
填空题设x、y、z均为int型变量,请写出描述"x或y中至少有一个小于z"的表达式______。
填空题以下程序从终端读入数据到数组中,统计其中正数的个数,并计算它们之和。请填空。 main() int i, a[20],sum, count; sum=count=0; for (i=0;i<20; i++) scanf("%d",(______); for(i=0;i<20; i++) if(a[i]>0) count++; sum+=(______); print f ( "sum=%d,count-%dkn" , sum, count);
填空题有以下程序: #include<stdio.h> main() int i,j,a[][3]=1,2,3,4,5,6,7,8,9; for(i=0;i<3;i++) for(j=i;j<3;j++)printf("%d",a[i][j]); printf("/n"); 程序运行后的输出结果是______。
填空题以下说明语句中,______是结构体类型名。 typedef struct int n; char ch[8]; PER;
填空题以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串 :abc123edf456gh,执行程序后输出:123456请填空. #include <stdio.h> #include <ctype.h> main() char s[80], d[80]; int i,j; gets(s); for (i=j=0;s[i]!='/0';i++) if( ) d[j]=s[i]; j++; d[j]='/0'; puts (d);
填空题在关系模型中,把数据看成是二维表,每—个二维表称为—个{{U}} [3] {{/U}}。
