填空题
给定程序MODI1.C中函数fun的功能是:从低位开始取出长整型变量s中偶数位上的数,依次构成一个新数放在t中。高位仍在高位,低位仍在低位。
例如,当s中的数为:7654321时,t中的数为:642。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
给定源程序:
#include<stdio.h>
/**********found**********/
void fun(long s, long t)
{long sl=10;
s/=10;
*t=s%10;
/**********found**********/
while(s<0)
{ s=s/100;
*t=s%10*sl+*t;
sl=sl*10;
}
}
main()
{long s, t;
printf("/nPlease enter s:"); scand("%ld",
fun(s,
printf("The result is:%ld/n", t);
}
填空题以下函数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++;}
}
填空题软件开发环境是全面支持软件开发全过程的______的集合。
填空题定义char ch="$";int i=1,j;执行j=!ch&&i++以后,i的值为______。
填空题数据模型是用来描述数据库的结构和语义的,数据模型有概念数据模型和结构数据模型两类,E-R模型是 【4】
填空题若有定义语句char s[100],d[100];int j=0,i==0;且s中已赋字符串,请填空以实现拷贝。 (注:不使用逗号表达式)
while(s[i]={{U}} {{U}} {{/U}} {{/U}};j++;}
d[j]=0;
填空题软件是由两部分组成的,一部分是______,另一部分是文档资料。
填空题下面程序的运行结果是: {{U}} 【17】 {{/U}}
int f( int a[ ], int n)
{ if(n>1) return a[0]+f(
else return a[0];}
main ( )
{ int aa[3]={1,2,3},s;
s=f( ; printf(“%d/n”,s);}
填空题SQL语句“SELECT TOP 10 PERCENT *FROM 订单 ORDER BY 金额 DESC”的查询结果是订单中金额______的10%的订单信息。
填空题下列给定程序的功能是调用fun()函数建立班级通信录。通信录中记录每位学生的编号、姓名和电话号码。班级人数和学生信息从键盘读入,每个人的信息作为一个数据块写到名为myfile5.dat的二进制文件中。请在标号处填入正确的内容,使程序得出正确的结果。
不得增行或删行,也不得更改程序的结构。
试题程序 #include
<stdio.h> #define N 5 typedef struct
{ int num; char name[10]; char
tel[10]; } STYPE; void check();
/* * * * *found* * * * * / int fun(______
*std) { /* * * * *found* * * * * / ______ *fp;
int i; if((fp=fopen("myfile5.dat", "wb"))==NULL)
return(0); printf("/nOutput data to file! /n");
for(i=0; i<N; i++) /* * * * *found* * * * * /
fwrite(
fclose(fp); return(1); }
main() {STYPE s[10]= { {1, "aaaaa", "111111"},
{1, "bbbbb", "222222"}, {1, "ccccc", "333333"}, {1, "ddddd", "444444"}, {1,
"eeeee", "555555"}}; int k=fun(s); if(k==1) {
printf("Succeed!"); check();} else printf("Fail!");
} void check() { FILE *fp; int
i; STYPE s[10]; if((fp=fopen("myfile5.dat",
"rb"))==NULL) { printf("Fail!!/n"); exit(0); }
printf("/nRead file and output to screen:/n"); printf("/n
numnametel/n"); for(i=0; i<N; i++) {
fread( printf("% 6d% s% s/n",
s[i]. num, s[i].name, s[i].tel); } fclose
(fp); }
填空题已有定义如下: struct node int data; struct node *next; *P; 以下语句调用malloc函数,使指针p指向一个具有struct node类型的动态存储空间。 请填空。 p=(struct node *)malloc 【19】 ;
填空题以下程序输出的最后一个值是______。 int ff(int n) static int f=1; f=f*n; retum f; main() int i; for(i=1;i<=5;i++) printf("%d/n",ff(i))i
填空题以下程序运行后的输出结果是______。 #include<stdio.h> main() int a=200, b=010; printf("%d%d/n", a, b);
填空题设i,j,k均为int型变量,则执行完下面的for语句后,k的值为 【14】 。 for(i=0,j=10;i<=j;i++,j--) k=i+j;
填空题以下程序运行后的输出结果是{{U}} 【14】 {{/U}}。
#include<stringh>
void fun(char*s,int p,int k)
{ int i;
for(i=p;i<k-1;i++)s[i]=s[i+2];
}
main()
{ char s[]="abcdefg";
fun(s,3,strlen(s));puts(s);
}
填空题有以下程序:#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<回车>,程序的输出结果是______。
填空题以下程序打开新文件f.txt,并调用字符输出函数将a数组中的字符写入其中。请填空。 #include<stdio.h> main() ______ *fp; char a[5]='1', '2', '3', '4', '5', i; fp=fopen("f.txt", "w"); for(i=0;i<5;i++) fputc(a[i], fp); fclose(fp);
填空题当运行以下程序时,从键盘输入abcdabcdef<CR> cde<CR> (<CR>表示回车),则下面程序的运行结果是 【15】 。 #include<stdio.h> main() int a;char s[80],t[80]; gets(s);gets(t); a=fun(s,t); printf("a=%d/n",a); fun(char*p,char*q) int i; char*p1=p; char*q1; for(i=0;*p!='/0';p++,i++) p=p1+i; if(*p!=*q)continue; for(q1=q+1,p=p+1;*p!='/0'&&*q1!='/0';q1++,p++) if(*p!=*q1) break; if(*q1=='/0') return i; return(-1);
填空题请补充main函数,该函数的功能是:从键盘输入一组字符串,以‘*’结束输入,并显示出这个字符串。
例如,输入abcdefghi*,结果显示adcdefghi。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio. h>
#define N 80
main ()
{
iht i=-l, j=0;
char str IN];
clrscr ();
printf("/n Input a string /n");
do
{
i++;
scanf({{U}}【1】{{/U}});
}while({{U}}【2】{{/U}});
printf ("/n**display the string** /n");
while (j<i)
{
printf ({{U}}【3】{{/U}});
j++;
}
}
填空题以下程序段的输出结果是( )。
#include
mian()
{ char *ch[4]={“red”,”green”,”blue”};
Int i=0;
While(ch[i]);
{ putchar(ch[i][0]; i++; }
}
