填空题程序的运行结果为 【6】 。 main() char c1='a',c2='b',c3='c'; printf("a%cb%c/tc%c/n",c1,c2,c3);
填空题下列程序的功能是计算数的阶乘。main() iht i,n; nlong np; scanf("%d",&n); np=______; for(i=2;i<=n;i++) ______; printf("n=%d n!=%ld/n",n,np);
填空题设int a=5,b=6,表达式(++a==b--)?++a:--b的值是______。
填空题下面程序的功能是输出数组s中最大元素的下标,请填空。
#include <stdio.h>
main()
{ int k, p,s[]={1, -9,7,2, -10,3};
for(p =0,k =p; p<6; p++)
if(s[p]>s[k]) {{U}}【13】 {{/U}}
printf("%d/n", k);
}
填空题下列给定程序中,函数fun的功能是:将形参s所指字符串中的所有字母字符顺序前移,其他字符顺序后移,处理后将新字符串的首地址作为函数值返回。
例如,若s所指字符串为“asd123fgh543df”,处理后新字符串为“asdfghdf123543”。
请在下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char*fun(char*s)
{int i,j,k,n;char*p,*t;
n=strlen(s)+1;
t=(char*)malloc(n*sizeof(char));
P=(char*)malloc(n*sizeof(char));
j=0;k=0;
for(i=0;i<n;i++)
{if(((s[i]>="a")&&(s[i]<="z"))||((s[i]>="A")&&(s[i]<="Z"))){
/********found********/
t[j]=______;j++;}
else
{p[k]=s[i];k++;}
}
/********found********/
for(i=0;i<______;i++)
t[j+i]=p[i];
/********found********/
t[j+k]=______;
return t;
}
main()
{char s[80];
printf("Please input:");
scanf("%s",s);
printf("/nThe result is:%s/n",fun (s));
}
填空题下列给定程序中,已建立一个带头结点的单向链表,链表中的各结点按结点数据域中的数据递增有序链接。函数fun的功能是:把形参x的值放入一个新结点并插入链表中,使插入后备结点数据域中的数据仍保持递增有序。
请在下划线处填入正确的内容并将下划线删除,使程序得出正确的结果。
注意
:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<stdlib.h>
#define N 8
typedef struct list
{int data;
struct list *next;
}SLIST;
void fun(SLIST *h,int x)
{SLIST *p,*q,*s;
s=(SLIST *)malloc(sizeof(SLIST));
/********found********/
s->data=______;
q=h;p=h->next;
while(p!=NULL
p=p->next;
}
s->next=p;
/********found********/
q->next=______;
}
SLIST *creatlist(int *a)
{SLIST *h,*p,*q;int i;
h=p=(SLIST *)malloc(sizeof(SLIST));
for(i=0;i<N;i++)
{q=(SLIST *)malloc(sizeof(SLIST));
q->data=a[i];p->next=q;p=q;
}
p->next=0;
return h;
}
void outlist(SLIST /h)
{SLIST *p;
p=h->next;
if(p==NULL)
printf("/nThe list is NULL!/n");
else
{printf("/nHead");
do
{printf("->%d",p->data);
p=p->next;
}while(p!=NULL);
printf("->End/n");
}
}
main()
{SLIST *head;int x;
int a[N]={11,12,15,18,19,22,25,29};
head=creatlist(a);
printf("/nThe list before inserting:/n");
outlist(head);
printf("/nEnter a number:");
scanf("%d",
fun(head,x};
printf("/nThe list after inserting:/n");
outlist(head);
}
填空题有以下程序 #include<stdio.h> main() int x,y; scarf("%2d%1d",&x,&y);printf("%d//n",x+y); 程序运行时输入:1234567,程序的运行结果是{{U}} {{/U}}。
填空题若有定义int a[4][4]={1,2,3,4},{0},{4,6,8,10},{1,3,5,7}},则初始化后,a[1][1]得到的初值是______。
填空题请补充main函数,该函数的功能是:从键盘输入两上字符串并分别保存在字符数组str1和str2中,用字符串str2替换字符串str1前面的所有字符,注意,str2的K度不大于str1,否则需要重新输入。
例如,如果输入strl;=“abced”,str2=“fk”,则输出“fkced”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仪在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<string. h>
main ()
{
char strl [ 81], str2 [ 81 ];
char *pl=strl, *p2=str2;
clrscr ();
do
{
printf(" Input strl tn");
gets (strl);
printf(" Input str2 In");
gets (str2);
}while({{U}}【1】{{/U}});
while({{U}}【2】{{/U}})
*p1++=*p2++;
printf(" Display strl /n");
puts ({{U}}【3】{{/U}})
}
填空题E-mail地址由域名和用户名两部分组成,它们之间用@分隔,其中在@后面的部分是【 】。
填空题以下程序的输出结果是【 】。
#include
main()
{char *sl,*s2,m;
sl=s2=(char*)malloc(sizeof(char)).
*sl=15; *s2=20; m=*sl+*s2;
printf("%d\n",m);
}
填空题下列程序的运行结果是______。 #include<stdio.h> func(a,b) static int m=0,i=2; i+=m+1; m=i+a+b; return(m); main() int k=5,m=3,p; p=func(k,m); printf("%d",p); p=func(k,m); printf("%d/n",p);
填空题下列给定程序中函数fun()的功能是计算正整数num的各位上的数字之平方和。
例如:输入352,则输出应该是38;若输入328,则输出应该是77。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <conio.h>
long fun(long num)
{
/*+**+*+*+*found************/
long k=1;
do
{
k+=(num%10)*(num%10);
num/=10;
/*********+found*+**+*+******/
}while(num)
return(k);
}
main()
{
long n;
clrscr();
printf("/Please enter a number:");
scanf("%ld",&n);
printf("/n%ld/n",fun(n));
}
填空题下面程序的功能是将一个字符串str的内容倒序,请填空。 #inelude <stdio.h> #include <strins.h> main() int i,j, 【15】 ; charstr[]="1234567"; for(i=0,j=strlen(str) 【16】 ;i<j; i++,j--) k=str[i];str[i]=str[j];str[j]=k; printf("%s/n",str);
填空题以下程序运行后输入:3,abcde<回车>,则输出结果是 【17】 。 #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];int n,i,z; scanf("%d,%s",i<=n;i++)move(s,z); printf("%s/n",s);
填空题有以下程序
#include
int fun(int n)
{ if(n == 0) return(1);
return(fun(n - 1) * n);
}
main()
{ int t;
t = fun(3); printf("%d\n", t);
}
程序运行后输出结果是U [14] /U。
填空题有以下程序,请在______处填写正确语句,使程序可正常编译运行。 #include<stdio.h> ______; main() (double x, y, (*p)(); scanf("%1f%1f", &x, &y); p=avg; printf("%f/n", (*p)(x, y)); double avg(double a, double b) return((a+b)/2);
填空题若有程序
main( )
{ int i,j;
scanf("i=%d,j=%d",
printf("i=%d,j=%d/n ",i,j);
}
要求给i赋10,给j赋20,则应该从键盘输入{{U}} 【7】 {{/U}}。
填空题以下程序运行后的输出结果是 【18】 。 fun(int x) if(x/2>0)fun(x/2); printf("%d",x); main() fun(6);
填空题以下程序的输出结果是______。 #include main() int a[5]=2,4,6,8,10, *p; p=a; p++; printf("%d",*p);
