填空题下列给定程序中,函数proc()的功能是:用冒泡法对6个字符串按由小到大的顺序进行排序。
请修改程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
#define MAX 20
//****found****
proc(char*pstr[6])
{
int i,j;
char*p;
for(i=0;i<5;i++)
{
for(j=i+1;j<6;j++)
//****found****
{
if(strcmp(*(pstr+i),pstr+j)>0)
{
p=*(pstr+i);
//****found****
*(pstr+i)=pstr+j;
*(pstr+j)=p;
}
}
}
}
void main()
{
int i;
char * pstr[6],str[6][MAX];
system("CLS");
for(i=0;i<6;i++)pstr[i]=str[i];
printf("/nEnter 6 string(1 string at eachline):/n");
for(i=0;i<6;i++)scanf("%s",pstr[i]);
proc(pstr);
printf("The strings after sorting:/n");
for(i=0;i<6;i++)printf("%s/n",pstr[i]);
}
填空题以下程序运行后的输出结果是______。 #include<stdio.h> main() int a=1, b=7; do b=b/2; a+=b; while(b>1); printf("%d/n", a);
填空题以下程序的功能是:输出a、b、c三个变量中的最小值。请填空。 #include<stdio.h> main() int a,b,c,t1,t2; scanf("%d%d%d",&a,&b,&c); t1=a<b?______; t2=c<t1?______; printf("%d/n",t2);
填空题以下程序运行后输入:3,abcde<回车>,则输出结果是{{U}} 【13】 {{/U}}。
# 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);
}
填空题以下isprime函数的功能是判断形参a是否为素数,如果是素数,函数返回1,否则返回0。请填空。 int isprime(int a) int i; for(i=2;i≤a/2;i++) if(a%==0) [11] ; [12] ;
填空题下列函数从字符数组s[]中删除和c一样的字符,请在下面横线处填空。
void delete(s,c)
char s[],c;
{int i,j;
for(i=j=0;______;i++)
if(s[i]!='c')
s[j++]=s[i];
s[j]="/0";}
填空题下列给定程序中函数proc的功能是:取出长整型变量s中偶数位上的数,依次构成一个新数放在t中。例如,当s中的数为123456789时,t中的数为2468。请修改程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
//****found****
void proc(long s,long t)
{long s1=10;
s/=10;
*t=s%10;
//****found****
while(s<0)
{ s=s/100;
*t=s%10*s1+*t;
s1=s1*10;
}
}
void main()
{ long s,t;
system("CLS");
printf("/nPlease enter s:");
scanf("%1d",
proc(s,
printf("The result is:%1d/n",t);
}
填空题以下程序的输出结果是{{U}} 【7】 {{/U}}。
main()
{ int a=177;
printf(“%o/n”,A) ;
}
填空题下面程序的输出走 【9】 。 main() enum em em1=3,em2=1,em3; char*aa[]="AA","BB","CC","DD"; printf("%s%s%s/n",aa[em1],aa[em2],aa[em3]);
填空题请补充函数proc(),该函数的功能是:从键盘输入一个下标n,把数组arr中比元素arr[n]小的元素放在它的左边,比它大的元素放在它的右边,排列成的新数组仍然保存在原数组中。
例如,数组arr={33,67,42,58,25,76,85,16,41,65},输入3。
结果输出“33,42,25,16,41,58,67,76,85,65”。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#define M 10
void proc(int arr[],int n)
{
int i,j=0,k=0,t;
int bb[M];
t=arr[n];
for(i=0;i<M;i++)
{
if(arr[i]>t)
bb[j++]=arr[i];
if(arr[i]<t)
arr[k++]=arr[i];
}
______;
for(i=0;______;i++,k++)
arr[k]=bb[i];
}
void main()
{
int i,n;
int arr[M]={33,67,42,58,25,76,85,16,41,65};
system("CLS");
printf("/n***original list***/n");
for(i=0;i<M;i++)
printf("%4d",arr[i]);
printf("n suffix n/n");
scanf("%d",
proc(arr,n);
printf("/n***new list***/n");
for(i=0;i<M;i++)
printf("%4d",arr[i]);
}
填空题下面程序是计算100以内能被4整除且个位数为4的所有整数,请填空。 main() int m,n; for(m=0; 【9】 ;m++) n=m*10+4; If( 【10】 )continue; printf("%d/n",n);
填空题若输入I have a test.#,则以下程序的运行结果为______。#include<stdio.h>main() FILE*fp; char str[100],filename[10]; int i=0; if ((fp=fopen("test","w"))==NULL) printf("can not open the file!/n"); exit(0); getchar(); gets(str); while(str[i]!='#') if (str[i]>='a' && str[i]<='z') str[i]=str[i]-32; fputc(str[i],fp); i++; fclose(fp); fp=fopen("test","r"); fgets(str,strlen(str)+1,fp); printf("%s/n",str); fclose(fp);
填空题以下程序的运行结果是______。
int x;
main()
{ int a=5,b=8;
swap(a,b) ;
printf("a=%d,b=%d,x=%d/n",a,b,x);
}
swap(int a,int b)
{ int temp;
temp=a;a=b;
b=temp;x=a/b;
printf("x=%d/n",x);
}
填空题数据库系统在其内部分为三级模式,即概念模式、内模式和外模式。其中,______给出了数据库物理存储结构与物理存取方法。
填空题以下程序运行后的输出结果是______。
#include<stdio.h>
typedef struct
{
int no; double score;
}REC;
void fun(REC x)
{
x.no=20; x.score=92.5;
}
int main()
{
REC a={10, 80.0};
fun(a);
printf("%d, %lf/n", a.no, a.score);
return 0;
}
填空题有以下程序:
main()
{ int a=7,b=8, *p, *q, *r;
p= q=
r=p; p=q; q=r;
printf("%d,%d,%d,%d/n", *p,*q,a,b);
}
程序运行后的输出结果是{{U}} 【1】 {{/U}}。
填空题请补充main函数,该函数的功能是:打印出1~1000中满足:个位数字的立方等于其本身所有数。 本题的结果为;1 64 125 216 729 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数main的横线上填入所编写的若干表达式或语句。 试题程序: #include <stdio .h> main ( ) int i,g; clrscr (); for (i=1; i<1000; i++) g= 【1】 ; if( 【2】 ) printf ("%4d", i);
填空题若有定义:int a=2, b=3; float x=3.5, y=2.5; ,则表达式(float)(a+b)/2+(int)x%(int)y的值是______。
填空题设有定义:int n,*k=&n;以下语句将利用指针变量k读写变量n中的内容,请将语句补充家整。seanf("%d", 【6】 );printf("%d/n", 【7】 );
填空题以下程序运行后的输出结果是【 】
main( )
{ int i,j,a[ ][3]={1,2,3,4,5,6,7,8,9};
for(i=0;i<3;i++)
for(j=i+1;j<3;j++) a[j][i]=0;
for(i=0;i<3;i++)
{ for(j=0;j<3;j++) printf("%d ",a[i][j]);
printf("/n");
}
}
