填空题以下程序的辅出结果是 【13】 。 void fun(int s[]) int i; for(i=0;i<10;i++)printf("%d",s[i]); printf("/n/n"); main() int a[3][4]=99,2,3,4,5,6,7,8; fun(a[0]);
填空题下列给定的程序中,函数fun()的功能是;将s所指字符串中出现的n所指字符串全部替换成t2所指字符串,所形成的新的字符串放在w所指的数组中。在此处,要求t1和t2所指字符串的长度相同。例如:当s所指字符串中所指的内容为 abcdabfab,t1所指字符串中的内容为ab,t2所指字符串中的内容为99时,结果在w所指的数组中的内容应为99cd99f99。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
/*************found**************/
int fun (char *s, char *t1, char *t2, char *w)
{
int i; 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;
/*************found**************/
while (*r){*a=*r;a++;r++}
w+=strlen(t2);
}
else w++;
}
}
main()
{char s[100],t1[100],t2[100],w[100];
clrscr();
printf("/nPlease enter string S: ");
scanf("%s",s);
printf("/nPleaseentersubstring t1: ");
scanf ("%s", t1);
printf("/nPlease enter substring t2: ");
scanf ("%s",t2);
if (strlen(t1)= =strlen(t2))
{
fun (s,t1,t2,w);
printf("/nThe result is : %s/n",w);
}
else printf("Error : strlen(t2)/n");
}
填空题请补充函数proc(),该函数的功能是:把字符串str中的字符按字符的ASCII码降序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。
例如,如果输入“abcdefg”,则输出为“gfedcba”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define N 80
void proc(char str[],int n)
{
int i,j;
char ch;
for(i=0;i<n;i++)
for(j=______;j<n;j++)
if(str[i]<str[j])
{
ch=str[j];
______;
str[i]=ch;
}
}
void main()
{
int i=0,strlen=0;
char str[N];
system("CLS");
printf("/nInput a string:/n");
gets(str);
while(str[i]!="/0")
{
strlen++;
i++;
}
proc(str,strlen);
printf("/n***display string***/n");
puts(str);
}
填空题以下程序的输出结果是{{U}} 【8】 {{/U}}。
main()
{
unsigned short a=65536;
int b;
printf("%d/n",b=A) ;
}
填空题下面程序的运行结果是, 。
#include<stdio.h>
void fun(int*s)
{
static int i=0;
do
{
s[i]+=s[i+1];
}while(++i<3);
}
int main()
{
int i, a[10]={0, 1, 2, 3, 4};
for(i=1; i<3; i++)
fun(a);
for(i=0; i<5; i++)
printf("%d", a[i]);
printf("/n");
return 0;
}
填空题已定义char ch='$';int i=1,j;,执行j!=ch&&i++以后,i的值为______。
填空题软件的可移植性是用来衡量软件 【2】 的重要尺度之一。
填空题有以下程序:#include <stdio.h>int sub(int n) return(n/10 + n% 10); main( ) int x,y; seanf(" %d" , y = sub (sub(sub (x))); printf(" %d /n";,y); 若运行时输入:1234<回车>,程序的输出结果是 【13】 。
填空题下列给定程序中,函数proc()的功能是逐个比较str1,str2两个字符串对应位置中的字符,把ASCII值大或相等的字符依次存放到str数组中,形成一个新的字符串。 例如,str1中的字符串为fshADfg,str2中的字符串为sdAEdi,则sir中的字符串应为sshEdig。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdio.h> #include<string.h> void proc(char *p, char *q, char *c) int k=0; while( *P||*q) //************found************* if (*p>=*q) c[k]=*q; else c[k]=*p; if(*p)p++; if(*q)q++; //************found************* k++ void main() char str1[10]="fshADfg", str2[10]="sdAEdi", str [80]='/0'; proc(str1, str2, str); printf("The string str1: "); puts(str1); printf("The string str2: "); puts(str2); printf("The result: "); puts(str);
填空题以下程序运行后的输出结果是 【4】 。 main() char c; int n=100; float f=10; double x; x=f* =n/=(c=50); printf("%d %f/n",n,x);
填空题程序测试分为静态分析和动态测试。其中______是指不执行程序,而只是对程序文本进行检查,通过阅读和讨论,分析和发现程序中的错误。
填空题以下程序运行后输入:3,abcde<回车>,则输出结果是______。 # include<string.h> move(char *str,int n) char temp int i; temp=str[n-1); for(i=n-1;i>0;i--)str[i]=str[i-1]; str[0]=temp main() char s[50];iht n,i,z; scanf("%d,%s", z=strlen(s); for(i=1;i<=n;i++)move(s,z); printf("%s/n",s);
填空题请完成函数fun(),它的功能是:用选择法对数组中n个元素按从大到小的顺序进行排序。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在下划线上填入所需的内容。
#include<stdio.h>
#define N 20
void fun(int a[],int n)
{
int i,j,t,p;
for(j=0;j<n-1;{{U}} 1 {{/U}})
{ p=j;
for(i=j;i<n;i++)
if(a[i]{{U}} 2 {{/U}}a[p]
p=i;
t=a[p];
a[p]=a[j];
a[{{U}} 3 {{/U}}]=t;
}
}
main()
{int a[N]={11,32,-5,2,14},i,m=5;
for(i=0;i<m;i++)
printf("%d/n",a[i});
fun(a,m);
for(i=0;i<m;i++)
printf("%d"a[i]);
}
填空题以下程序用来判断指定文件是否能正常打开,请填空。
#include<stdio.h>
main()
{FILE*fp;
if(((fp=fopen("test.txt","r"))={{U}} 【13】 {{/U}}))
printf("未能打开文件!/n");
else
printf("文件打开成功!/n");
}
填空题给定程序中函数fun的功能是:求三个数的最小公倍数。
例如,给主函数中的变量x1、x2、x3分别输入15 11 2,则输出结果应当是:330。
请改正程序中的错误,使它能得出正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
给定源程序:
#include<stdio.h>
/************found************/
fun(int x,y,z)
{int j,t,n,m;
j=1;
t=j%x;
m=j%y;
n=j%z;
while(t!=0||m!=0||n!=0)
{j=j+1;
t=j%x;
m=j%y;
n=j%z;
}
/************found************/
return i;
}
main()
{int x1,x2,x3,j;
printf("Input x1 x2 x3:");
scanf("%d%d%d",
printf("x1=%d,x2=%d,x3=%d/n",x1,x2,x3);
j=fun(x1,x2,x3);
printf("The minimal common multiple is:%d/n",j);
}
填空题一个栈的初始状态为空。首先将元素5,4,3,2,1依次入栈,然后退栈一次,再将元素A,B,C,D依次入栈,之后将所有元素全部退栈,则所有元素退栈(包括中间退栈的元素)的顺序为{{U}} (1) {{/U}}。
填空题以下程序按下面指定的数据给x数组的下三角置数,并按如下形式输出:请填空。 4 3 7 2 6 9 1 5 8 10 #include<stdio.h> main( ) int x[4][4],n=0,i,j; for(j=0;j<4;j++) for(i=3;i>=j;{{U}} {{/U}})n++;x[i][j]={{U}} {{/U}}; for(i=0;i<4;i++) for(j=0;j<=i;j++) printf("%3d",x[i][j]); printf("//n");
填空题常见的软件开发方法有结构化方法和面向对象方法。对某应用系统经过需求分析建立数据流图(DFD),则应采用U 【3】 /U方法。
填空题以下程序运行后的输出结果是______。 #defihe S(x) 4*x*x+1 main() int i=6,j=8; printf("%d/n",S(i+j));
填空题假设用一个长度为100的数组(数组元素的下标从0~99)作为栈的存储空间,栈底指针bottom指向栈底元素,栈顶指针top指向栈顶元素,如果bottom=99,top=60(数组下标),则栈中具有______个元素。