题目内容 (请给出正确答案)
[主观题]

下列给定程序中函数fun()的功能是;从低位开始取出长整型变量s中奇数位上的数,依次构成一个新数放

下列给定程序中函数fun()的功能是;从低位开始取出长整型变量s中奇数位上的数,依次构成一个新数放在t中。例如,当s中的数为4576235时,t中的数为4725。

请改正程序中的错误,使它能得到正确结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。

试题程序:

include<stdio.h>

include<conio.h>

/************found*************/

int fun(long S,long *t)

{

long s1=l0;

*tiS%10;

while(s>0)

{

/*************found*************/

s=s%100;

*t=S%10*S1+*t;

s1=s1*10;

}

}

main()

{

long S,t;

clrscr();

printf("\nPIease enter S:");

scanf(“%ld”,&s);

fun(S,&t);

printf(“The result is:%ld\n”,t);

}

查看答案
如搜索结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能会需要:
您的账号:
发送账号密码至手机
发送
更多“下列给定程序中函数fun()的功能是;从低位开始取出长整型变…”相关的问题

第1题

执行以下程序的输出结果是( )。 include<stdio.h>define M 5define N M+M main(){int k; k=N*N*5;

执行以下程序的输出结果是( )。

include<stdio.h>

define M 5

define N M+M

main()

{ int k;

k=N*N*5;printf(”%d\n" ,k);

}

点击查看答案

第2题

以下程序的作用是:从名为filea.dat的文本文件中逐个读入字符并显示在屏幕上。请填空。 include<

以下程序的作用是:从名为filea.dat的文本文件中逐个读入字符并显示在屏幕上。请填空。

include <stdio.h>

main()

{FILE *fp; char ch;

fp=fopen(【 】);

ch=fgetc(fp);

while(!feof(fp)) { putchar(ch); ch=fgetc(fp); }

putchar('\n');fclose(fp);

}

点击查看答案

第3题

以下程序运行后的输出结果是( )。 main(){int x,a=1,b=2,c=3,d=4;{int x,a=1,b=2,c=3,d=4;x=(a<B)

以下程序运行后的输出结果是( )。

main()

{ int x,a=1,b=2,c=3,d=4;

{ int x,a=1,b=2,c=3,d=4;

x=(a<B)?a:b;x=(a<C)?x:C;x=(d>x)?x:d;

printf("%d\n",x);

}

点击查看答案

第4题

以下程序运行后的输出结果是( )。 include char*ss(char*s) {char*p,t; P=s+1;t=*s;while(*p){ *(

以下程序运行后的输出结果是( )。

include

char*ss(char*s)

{char*p,t;

P=s+1;t=*s;

while(*p){ *(P-1)=*P;P++;}

*(P-1)=t;

return s;

}

main()

{char*p,str[10]="abcdefgh";

p=ss(str);

printf("%s\n",p);

}

点击查看答案

第5题

下列给定的程序中,函数hn()的功能是:为一个偶数寻找两个素数,这两个素数之和等于该偶数,并将这两

个素数通过形参指针传回主函数。

请改正函数fun()中的错误,使它能得出正确的结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。

试题程序:

include <stdio.h>

include <math.h>

void fun(int a, int *b, int *c)

{ int i,j,d,y;

for (i=3;i<=a/2;i=i+2)

/*************found**************/

{y=0;

for (j=2;j<=sqrt((double)i);j++)

if (i%j==0) y=0;

if (y==1)

/*************found**************/

{ d=i-a;

for (j-2;j<=sqrt((double)d);

j++)

if (d%j==0) y=0;

if (y=-1)

{*b=i; *c=d;}

}

}

}

main ()

{ int a,b,c;

do

{ printf("\nInput a: ");

scanf ("%d", &a); }

while (a%2);

fun (a, &b, &c);

printf ("\n\n%d=%d+%d\n", a,b,c);

}

点击查看答案

第6题

请补充函数fun,该函数的功能是比较字符串str1和str2的大小,井返回比较的结果。 例如:当str1=“cdef

请补充函数fun,该函数的功能是比较字符串str1和str2的大小,井返回比较的结果。

例如: 当str1=“cdef",str2=“cde”时,函数fun()返回“>”。

注意:部分源程序给出如下。

请勿改动主函数main 和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。

试题程序:

include< stdio, h>

include<conio. h>

define N 80

char *fun (char *str1,char *str2)

{

char *p1=str1, *p2=str2;

while (*p1 & & *p2 )

{

if (【 】)

return "<";

if(【 】)

return ">";

p1++;

p2++;

}

if (*p1=*p2)

return "==";

if (*p1==【 】)

return "<";

else

return ">";

}

main()

{

char str1 [N], str2 [N];

clrscr ();

printf ("Input str1: \n");

gets (str1);

printf ("Input str2: \n");

gets (str2);

printf ("\n*****the result*****\n");

printf ("\nstr1 %s str2", fun (str1, str2) );

}

点击查看答案

第7题

请补充函数fun(),该函数的功能是建立一个带头结点的单向链表并输出到文件“out98.dat”和屏幕上,各

结点的值为对应的下标,链表的结点数及输出的文件名作为参数传入。

注意:部分源程序给出如下。

请勿改动主函数main 和其他函数中的任何内容,仪在函数fun()的横线上填入所编写的若干表达式或语句。

试题程序:

include<stdio. h>

include<conio. h>

include<stdlib. h>

typedef struct ss

{

int data;

struct ss *next;

} NODE;

void fun(int n,char*filename)

{

NODE *h,*p, *s;

FILE *pf;

int i;

h=p= (NODE *) malloc (sizeof (NODE));

h->data=0;

for (i=1; i {

s=(NODE *)malloc (sizeof (NODE));

s->data=【 】;

【 】;

p=【 】

}

p->next=NULL;

if ( (pf=fopen (filename, "w") ) ==NULL)

{

printf {"Can not open out9B.clat! ");

exit (0);

}

p=h;

fprintf (pf, "\n***THE LIST***\n");

print f ("\n***THE LIST***\n")

while (p)

{

fprintf (pf, "%3d", p->data)

printf ("%3d",p->data);

if (p->next ! =NULL)

{

fprintf (pf, "->");

printf ("->");

}

p=p->next;

}

fprintf (pf, "\n");

printf ("\n");

fclose (pf);

p=h;

while (p)

{

s=p;

p=p->next;

free (s);

}

}

main()

{

char * filename="out98. dat";

int n;

clrscr ();

printf (" \nInput n: ");

scanf ("%d", &n);

fun (n, filename);

}

点击查看答案

第8题

以下程序可把输入的十进制数以十六进制数的形式输出。 请在横线上填上适当的内容并把横线删除,使

以下程序可把输入的十进制数以十六进制数的形式输出。

请在横线上填上适当的内容并把横线删除,使它能得出正确的结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。

试题程序;

main ()

{

char b[17]={"0123456789ABCDEF"};

int c[64] ,d,i=0,base=16;

long n;

printf("Enter a number:\n");

scanf ("%ld", &n);

do {

/*****************found****************/

c[i]=______; i++; n=n/base; }

while (n!=0);

printf("Transmite new base:\n");

for(--i;i>=0;--i)

/***************found*******************/

{ d=c[i];printf("%c",b______);}

printf("\n");

}

点击查看答案

第9题

下列给定程序中,函数fun()的功能是:删除字符串s中所有空白字符(包括Tab字符、回车符及换行符)。输

入字符串时用’’结束输入。

请改正程序中的错误,使它能得出正确的结果。

注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.

试题程序:

include <string.h>

include <stdio.h>

include <ctype.h>

fun(char *p)

{ int !i, t; char c[80];

for(i=0,t=0;p[i];i++)

if(!isspace(*(p+i))) c[t++]=p[i];

/**********************************/

c[t]='\0';

strcpy(p,c);

}

main()

{char c,s[80];

int i=0;

printf("Input a string: ");

c=getchar();

while(c!='')

( s[i]=c;i++;c=getchar();}

s[i]="\0";

fun(s);

puts(s);

}

点击查看答案

第10题

以下程序运行后的输出结果是( )。 include<stdio.h> main(){ int a=1, b=7; do { b=b/2; a+=b

以下程序运行后的输出结果是( )。

include<stdio.h>

main()

{ int a=1, b=7;

do {

b=b/2; a+=b;

} while(b>1);

printf("%d\n",A);

}

点击查看答案
热门考试 全部 >
相关试卷 全部 >
账号:
你好,尊敬的上学吧用户
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
谢谢您的反馈

您认为本题答案有误,我们将认真、仔细核查,
如果您知道正确答案,欢迎您来纠错

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
上学吧
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反上学吧购买须知被冻结。您可在“上学吧”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
上学吧
点击打开微信