填空题下列程序的运行结果是 【11】 。 #include<stdio.h> void main() int s=0,k; for(k=7;k>4;k--) switch(k) case 1: case 4: case 7:s++;break; case 2: case 3: case 6:break; case 0: case 5:s+=2;break; printf("s=%d" ,s);
填空题下列程序的功能是将字符串s中所有的字符c删除。请填空。
#include<stdio.h>
main()
{char s[80];
int i,j;
gets(S);
for(i=j0;s[i]!'/0';i++)
if(s[i]!='c')______;
s[j]='/0;
puts(S);
}
填空题以卜函数sstrcat()的功能是实现宁符串的连接,即将t所指字符串复制到s所指字符串的尾部。例如:s所指字符串为abcd,t所指字符申为efgh,函数调用后s所指字符串为abcdefgh。请填空。
#include <string.h>
void sstrcat(char *s, char *t)
{ int n;
n=strlen(s);
while(*(s+n)= ){s++;t++;}
}
填空题下列给定程序中,函数proc()的功能是:通过某种方式实现两个变量值的交换,规定不允许增加语句和表达式。例如变量num1中的值原为2,num2中的值原为1,程序运行后num1中的值为1,num2中的值为2。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
int proc(int*x,int y)
{
int t;
//****found****
t=x;
*x=y;
//****found****
return(y);
}
void main()
{
int num1=2,num2=1;
system("CLS");
printf("%d%d/n",num1,num2);
num2=proc(
printf("%d%d/n",num1,num2);
}
填空题有以下程序 main() int t=1,i=5; for( ; i>=0; i--) t*=i; printf("%d/n",t); 执行后输出结果是______。
填空题以下程序中,for循环体执行的次数是 【13】 。 #define N 2 #define M N+1 #define K M+1*M/2 main() int i; for(i=1;i<K;i++) …
填空题请补充函数proc(),该函数的功能是:把一个字符串中的数字字符按从大到小的顺序排序,并把这个全部由数字组成的字符串保存在原串中,函数返回数字字符串的长度。例如,若输入字符串为“abc123def”,如果为321,字符串长度为3。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define M 20
int proc(char *str)
{
int i=0, j=0, k=0, m=0;
char t;
char *p=str;
while(*p)
{
if(*p>="0"
p++;
}
*(str+i)="/0";
______;
while(*(p+j))
{
k=j;
______;
while(*(p+k))
{
if(*(p+k)>*(str+m))
{
t=*(str+m);
*(str+m)=*(p+k);
*(p+k)=t;
}
k++;
}
j++;
}
return i;
}
void main()
{
char str[81];
int n;
system("CLS");
printf("Input the original string");
gets(str);
printf("***The original string***/n");
puts(str);
printf("***The new string***/n");
n=proc(str);
puts(str);
printf("***The length of new string is: %d***/n", n);
}
填空题以下程序是求矩阵a,b的和,结果存入矩阵c中,并按矩阵形式输出,请填空。 #include<stdio.h> main() int a[3][4]=13,-2,7,5,1,0,4,-3,6,8,0,2; int b[3][4]=-2,0,1,4,5,-1,7,6,6,8,0,2; int i,j,c[3][4]; for(i=0;i<3;i++) for(j=0;j<4;j++) c[i][j]= 【18】 ; for(i=0;i<3;i++) for(j=0;j<4;j++) printf("%3d",c[i][j]); printf("/n");
填空题以下程序运行后的输出结果是{{U}} 【5】 {{/U}}。
int a=5;
fun(int b)
{ static int a=10;
a+=b++;
printf("%d",a);
}
main()
{ int c=20;
fun(c);
a+=c++;
printf("%d/n",a);
}
填空题以下程序的功能是输入任意整数给 n 后,输出 n 行由大写字母 A 开始构成的三角形 字符阵列图形。例如,输入整数 5 时(注意:n 不得大于 10),程序运行结果如下:
A B C D E F G H I
J K L M N O
请填空完成该程序。
main()
{ int i,j,n; char ch=''A'';
scanf("%d",
if(n<11)
{ for(i=1;i<=n;i++)
{ for(j=1; j<=n-i+1;j++)
{ printf("%2c",ch);
_______ ;
}
_______ ;
}
}
else printf ("n is too large!/n");
printf("/n");
}
填空题下面的程序实现字符串的复制。 void copy_string(from,to) 【14】 ; for(;*from;from++,to++) *to=*from; 【15】 ; main() char *a="I am wang",*b="you are Li"; printf ("%s/n%s/n",a,b); 【16】 ; printf("%s/n%s/n/n",a,b);
填空题有以下程序;
int a=2;
int f(int *A)
{return(*A) ++;}
main()
{ int s=0;
{ int a=5;
s+=f(&A)
}
s+=f(&A)
printf("%d/n",s)
}
执行后的输出结果是{{U}} 【8】 {{/U}}。
填空题下列程序的输出结果是______。 #include<stdio.h> main() intx=10,y=10,i; for(i=0;x>8;y=++) printf("%d%d",X--,y);
填空题请补充函数fun(),该函数的功能是:按行统计N×N维矩阵元素中的最大值(均为整数),并把这些值按从小到大的顺序保存在数组b中。矩阵的维数在主函数中输入,并赋予随机数。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<conio.h> #include<stdlib.h> #define N 20 void fun( 【1】 ) int i j; int t; for(i=0;i<n;i++) for(j=0;j<n;j++) if( 【2】 ) b[i]=a[i][j]; for(i=0;i<n;i++) for(j=0;i<n;j++) if( 【3】 ) t=b[i]; b[i]=b[j]; b[j]=t; main() int a[N][N]; int b[N]; int n; int i,j; clrscr(); printf("*****Input the dimension of array N*****/n"); scanf("%d",&n); printf("*****The array *****/n"); for(i=0;i<n;i++) for(j=0;i<n;j++) a[i][j]=rand()%20; while(a[i][j]==0) a[i][j]=rand()%30; printf("%4d",a[i][j]); printf("/n/n"); for(i=0;i<n;i++) b[i]=0; fun(a,b,n); printf("***** THE RESULT *****/n"); for(i=0;i<n;i++) printf("%d",b[i]);
填空题在进行模块测试时,要为每个被测试的模块另外设计两类模块:驱动模块和承接模块(桩模块)。其中{{U}} 【4】 {{/U}}的作用是将测试数据传送给被测试的模块,并显示被测试模块所产生的结果。
填空题以下程序运行后的输出结果是 【12】 。 #include <stdio.h> main( ) int x=1,y=0,a=0,b=0; switch ( x ) case 1:switch(y) case 0:a ++; break; case 1 :b ++; break; case 2:a ++ ;b +*; break; printf("%d %d/n",a,b);
填空题请补充函数proc(),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。
例如,str1="I am a",str2="student",结果输出:I am a student。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define M 40
void proc(char*str1,char*str2)
{
int i=0;
char*p1=str1;
char*p2=str2;
while(______)
i++;
for(;______;i++)
*(p1+i)=______;
*(p1+i)="/0";
}
void main()
{
char str1[M],str2[M];
system("CLS");
printf("****Input the string str1
printf("/nstr1:");
gets(str1);
printf("/nstr2:");
gets(str2);
printf("**The string str1
puts(str1);
puts(str2);
proc(str1,str2);
printf("****The new string****/n");
puts(str1);
}
填空题下述函数统计字符串中的单词个数,单词是指处在空格之间的字符序列,请填空。 int word(char*s) int num=0,flag=0; while(*s) if({{U}} {{/U}}=") flag=0; else if{{U}} {{/U}}flag=1;num++ return{{U}} {{/U}};
填空题设有以下宏定义
#define W 5
#define L (W+2)
则执行赋值语句p=L*2;(p为int 型变量)后,p的值为______。
填空题下列程序的输出结果是 【6】 。 main() int a=1,b=2; a=a+b;b=a-b;a=a-b; prrintf("%d,%d/n",a,b) ;
