填空题下列程序执行后输出的结果是{{U}} 【9】 {{/U}}。
main()
{ int arr[10],i,k=0);
fot(i=0;i<10;i++)art[i]=i;
for(i=1:i<4;i++) k+=arr[i]+i;
printf("%d/n",k);
}
填空题下列给定程序中,函数proc()的功能是根据整型形参n,计算如下公式的值:
y=1-1/(22)+1/(33)-1/(44)+…+(-1)(n+1)/(nn)
例如,n中的值为10,则应输出0.817962。
请修改程序中的错误,使它能得到正确结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
double proc(int n)
{
double y=1.0;
//****found****
int j=1;
int i;
for(i=2;i<=n;i++)
{
j=-1*j;//****found****
y+=1/(i*i);
}
return(y);
}
void main()
{
int n=10;
system("CLS");
printf("/nThe result is%lf/n",proc(n));
}
填空题以下程序的功能是:借助指针变量找出数组元素中最大值所在的位置并输出该最大值。请在输出语句中填写代表最大值的输出项。 #include<stdio.h> main() int a[10], *p, *s; for(p=a;p-a<10;p++) scanf("%d", p); for(p=a, s=a;p-a<10;p++) if(*p>*s) s=p; printf("max=%d/n", ______);
填空题下列给定程序中,函数proc()的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码升序排序后输出。
例如,输入opdye,则应输出deopy。
请修改程序中的错误,使它能得到正确结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
//****found****
int proc(char str[])
{
char c;
unsigned i,j;
for(i=0;i<strlen(str)-1;i++)
for(j=i+1;j<strlen(str);j++)
if(str[i]>str[j])
{
c=str[j];
{|****found****
str[j]=str[i++];
str[i]=c;
}
}
void main()
{
char str[81];
system("CLS"):
printf("/nPlease enter a character
string:");
gets(str);
printf("/n/nBefore sorting:/n%S",str);
proc(str);
printf("/nAfter sorting decendingly:n%S",str);
}
填空题以下函数rotate的功能是:将a所指N行N列的二维数组中的最后一行放到b所指二维数组的第0列中,把a所指二维数组中的第0行放到b所指二维数组的最后一列中,b所指二维数组中其他数据不变。 # define N 4 void rotate(int a[][N], int b[][N]) int i, j; for(i=0; i<N; i++) b[i][N-1]=a[0][i];{{U}} {{/U}}=a[N-1][i];
填空题指针变量p和数组a的说明如下: int*a[3]="aa","bb","cc",**p; 执行语句p=后,*p指向的字符串是______。
填空题以下程序的功能是:输出a、b、c三个变量中的最小值。请填空。 #include<stdio.h> main() int a,b,c,t1,t2; scanf("%d%d%d",&a,&b,&c); t1=a<b? (9) ; t2=c<t1? (10) ; printf("%d/n",t2);
填空题数据独立性分为逻辑独立性与物理独立性。当数据的存储结构改变时,其逻辑结构可以不变,因此,基于逻辑结构的应用程序不必修改,称为{{U}} [5] {{/U}}。
填空题有下面的程序:#include <stdio, h>main ( ) enum team my,your=4,his,her=his+10; prinff(" % d %d %d %d //n" ,my,your,his,her);此程序的输出结果是{{U}} {{/U}}。A) 0 1 2 3 B) 0 4 0 1 0 C) 0 4 5 1 5 D) 1 4 5 1 5
填空题在进行软件结构设计时,应遵循的最主要原理是
________
。
填空题以下函数用来求出两整数之和,并通过形参将结果传回。请填空。 void func(int x,int y, 【10】 z) * z=x+y;
填空题以下程序用于判断a、b、c能否构成三角形,若能,输出YES,否则输出NO。当给a、b、c输入三角形三条边长时,确定a、b、c能构成三角形的条件是需同时满足三个条件:a+b,c,a+c>b,b+c>a。请填空。 main() float a,b,c; scanf("%f%f%f", if( [9] )printf("YES/n"); /*a、b、c能构成三角形*/ else printf("NO"); /*a、b、c不能构成三角形*/
填空题以下程序运行后输出结果是U 【9】 /U。
#include
main()
{ int i,n[]={0,0,0,0,0};
for(i=1;i<=2;i++)
{ n[i]=n[i-1]*3+1;
printf("%d ",n[i]);
}
printf("\n");
}
填空题以下程序的输出结果是{{U}} 【13】 {{/U}}。
#include <stdio.h>
#include <string.h>
char *fun(char *0
{ char *p--t;
return (p+strlen(t)/2);
}
main()
{ char *str="abcdefgh";
str=ftm(str);
puts(str);
}
填空题若k为int型变量且赋值11。请写出运算k++后表达式的值______和变量k的值______。
填空题下面程序的运行结果是______。 #include<stdio.h> #define SlZE 12 main() char s[SIZE];int i; for(i=0;i<SIZE;i++) s[i]='A'+i+32; sub(s,5,SIZE-1); for(i=0;i<SIZE;i++)printf("%c",s[i]); printf("/n"); sub(char *a,int t1,int t2) char ch; while(t1<t2) ch=*(a+t1); *(a+t1)=*(a+t2); *(a+t2)=ch; t1++;t2--;
填空题以下程序的功能是:借助指针变量找出数组元素中的最大值及其元素的下标值。请填空。 #include<stdio.h> main() int a[10],*p,*s; for(p=a;P-a<10;p++)scanf("%d",p); for(p=a,s=a;p-a<10;p++)if(*p>*s)s=______; printf("index=%d/n",s-a);
填空题下列程序执行后输出的结果是 【9】 。main() int arr[10],i,k=0; for(i=0;i<10;i++)arr[i]=i; for(i=1;i<4;i++) k+=arr[i]+i; printf("%d/n",k);
填空题以下程序的功能是从键盘输入若干学生的成绩,并输出最高成绩和最低成绩,当输入负数时结束。请填空。 main( ) float x,amax,amin; scanf("%f", amin=x: while( (7) ) if(x>amax) amax=X; else if (8) amin=X; else scanf("%f",&x); printf("/n amax=%f/n amin=%f/n",amax,amin);
填空题如果一个工人可管理多个设备,而一个设备只被一个工人管理,则卖体“工人”与实体“设备”之间存在{{U}} 【4】 {{/U}}关系。