填空题以下程序是用递归方法求数组中的最大值及其下标值。请填空。
#define M 10
void findmax(int *a,int n,int i,int *pk)
{ if(i<n)
{ if(a[i]>a[ *pk]){{U}} 【15】 {{/U}};
findmax(a,n,i+1,i++)scanf("%d" ,a+i);
findmax(a,M,0,&n);
printf(" The maxinum is:%d/n" ,a[n]);
printf(" It's index is;%d/n" ,n);}
填空题以下程序段的输出结果是{{U}} 【6】 {{/U}}。
int i=9;
printf("%o/n",i);
填空题下列给定程序中,fun()函数的功能是:根据形参m,计算下列公式的值。 t=-1+1/2+1/3+1/4+…+1/m 例如,若输入5,则应输出2.283333。 请改正程序中的错误,使它能计算出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <conio.h> #include <stdio.h> double fun(int m) double t=1.0; int i; for(i=2;i<=m;i++) /*************found**************/ t+=1.0/k; /*************found**************/ return i; main() int m; clrscr(); printf("/nPlease enter linteger number:"); scanf("%d", printf("/nThe result is%1f/n", fun(m));
填空题下列给定程序中函数fun的功能是:逐个比较p、q所指两个字符串对应位置上的字符,并把ASCII值大或相等的字符依次存放到c所指的数组中,形成一个新的字符串。
例如,若主函数中a字符串为“aBCDeFgH”,b字符串为“Abcd”,则c中的字符串应为“aBcdeFgH”。
请改正程序中的错误,使它能得出正确的结果。
注意:部分源程序在文件MODI1.C中,不得增行或删行,也不得更改程序的结构!
#include <stdio.h>
#include <string.h>
void fun(char *p,char *q,char*c)
{
/* * * * * * * * * * * *found* * * * * * * * * * * */
int k=1;
/* * * * * * * * * * * *found* * * * * * * * * * * */
while(*p!=*q)
{if(*p<*q)c[k]=*q;
else c[k]=*p;
if(*p)p++;
if(*q) q++;
k++;
}
}
main( )
{char a[10]="aBCDeFgH",b[10]="ABcd",c[80]={"/0"};
fun(a,b,c);
printf("The string a:");puts(a);
printf("The string b:");puts(b);
printf("The result:");puts(c);
}
填空题下列程序的输出结果是______。 main() int a=2,b=4,c=6; int*p1= *(p= printf("%d/n",c);
填空题对长度为10的线性表进行冒泡排序,最坏情况下需要比较的次数为______。
填空题有序线性表能进行二分查找的前提是该线性表必须是【1】存储的。
填空题下列给定的程序中,函数proc()的功能是:计算并输出m以内最大的6个能被7或11整除的自然数之和。m的值由主函数传入。例如,若m的值为600,则函数的值为3515。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdlib.h> #include<stdio.h> #include<conio.h> int proc(int k) int m=0, mc=0; //************found************* while(k>=2) me++; k--; return m; void main() system("CLS"); printf("%d/n", proc(600));
填空题以下程序段打开文件后,先利用fseek函数将文件位置指针定位在文件末尾,然后调用ftell函数返回当前文件位置指针的具体位置,从而确定文件长度,请填空。 FILE*myf;longfl; myf= 【15】 ("test.t","rb"); fseek(myf,(),SEEK_END) fl+ftell(myf); fclose(myf); printf("%ld/n",fl);
填空题以下程序的功能是:输出100以内(不含100)能被3整除且个位数为6的所有整数,请填空。 #include <stdio.h> main() int i,j for(i=0; 【15】 ;i++) j=i*10+6; if( 【16】 )continue: Printf("%d”",j);
填空题若变量已正确定义,在执行以下while语句时,输入字符A后,ch的值是______。
while(ch=getchar()=='A');
填空题变量i、j、k已定义为int型并均有初值0,用以下语句进行输入时:
scanf("%d", &i); scanf("%d", &j); scanf("%d", &k);
从键盘输入:
12.3<CR> (<CR>代表Enter键)
则变量i、j、k的值分别是______、______、______。
填空题请补充函数proc(),该函数的功能是:删去一维数组中所有相同的数,使之只剩一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。
例如,若一维数组中的数据是:1 1 2 2 2 3 4 4 5 5 6 6 6 7 7 8 10 10。
删除后,数组中的内容应该是:1 2 3 4 5 6 7 8 10。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define M 80
int proc(int arr[], int n)
{
int i, t, j=0;
t=arr[0];
for(i=1; i<n; i++)
if(______)
;
else
{
______;
t=arr[i];
}
arr[j++]=t;
return j;
}
void main()
{
int arr[M]={1, 1, 2, 2, 2, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 10, 10}, i, n=18;
printf("The original data: /n");
for(i=0; i<n; i++)
printf("%4d", arr[i]);
n=proc(arr, n);
printf("/n/nThe data after deleted; /n");
for(i=0; i<n; i++)
printf("%4d", arr[i]);
printf("/n");
}
填空题下面程序把从终端读入的文本(用@作为文本结束标志)输出到一个名为bi.dat的新文件中,请填空。
#include "stdio.h"
FILE *fp;
main()
{ char ch;
if((fp=fopen({{U}} 【16】 {{/U}}))==NULL)exit(0);
while((ch=getchar())!='@')fputc(ch ,fp);
fclose(fp);
}
填空题若有如下定义: int x=2,y=3,z=4; 则表达式!(x=y)||x+z&&y-z的值是 【9】 。
填空题已定义char ch="$";int i=1,j;执行j=!ch&&i++以后,i的值为______。
填空题下述函数用于统计一行字符中的单词个数,单词之间用空格分隔。
word num (str)
char str[];
{int i,num=0,word=0;
for(i=0;str[i]!={{U}} 【15】 {{/U}};i++)
if({{U}} 【16】 {{/U}}==)word=0;
else if(word==0)
{
word=1;
{{U}} 【17】 {{/U}};
}
return(num);
}
填空题下列程序的输出结果是{{U}} 【8】 {{/U}}。
main()
{ int a=1,b=2;
a=a+b;b=a-b,a=a-b;
printf("%d,%d/n",a,b) ;
}
填空题在面向对象方法,类之间共享属性和方法的机制称为______。
填空题以下程序运行后的输出结果是{{U}} 【8】 {{/U}}。
#include <stdio.h>
main()
{ int a=1,b=3,c=5;
if (c=a+b) printf("yes/n");
else printf("no/n");
}
