niusouti.com

请将以下程序中的函数声明语句补充完整#include <stdio.h>int【12】 ;main( ){int x,y,(*p)();p=max;printf(“&d\n”,&x,&y);}Int max(int a,int b){return (a>b/a:b);}

题目

请将以下程序中的函数声明语句补充完整

#include <stdio.h>

int【12】 ;

main( )

{int x,y,(*p)();

p=max;

printf(“&d\n”,&x,&y);

}

Int max(int a,int b)

{return (a>b/a:b);}


相似考题
更多“请将以下程序中的函数声明语句补充完整 #include &lt;stdio.h&gt; int【12】 ; main( ) {i ”相关问题
  • 第1题:

    请将以下程序中的函数声明语补充完整。 include int【】 main(){int x,y,(*p)(); sccanf("

    请将以下程序中的函数声明语补充完整。

    include<stdio.h>

    int【 】

    main()

    { int x,y,(*p)();

    sccanf("%d%d",&x,&y);

    p=max;

    printf(%d\n",(*p)(x,y));

    }

    int max(int a,int b)

    {return(a>b?a:b);}


    正确答案:max(int aint b)
    max(int a,int b) 解析:在C语言中,除了主函数外,对于用户定义的函数都遵循“先定义,后使用”的规则,若把函数定义放在调用之后,应该在调用之前对函数进行说明(或称为函数原型说明)。
    函数的说明形式为:
    类型名 函数名(参数类型1,参数类型2……)
    本题是通过max()函数来求出a和b中较大的数,由于max()函数的位置在main()函数之后,想要在main()函数中调用max()函数,就必须先在main()函数之前对max()函数进行说明,因为当在所有函数外部、被调用之前说明函数时,在对函数进行说明的语句后面所有位置上都可以对该函数进行调用。所以,在横线上应该填上被调函数的说明语句即 max(int a,int b) 。

  • 第2题:

    请补充main函数,该函数的功能是:从键盘输入若干字符放到一个字符数组中,当桉回车键时结束输入,最后输出这个字符数组中的所有字符。

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

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

    试题程序:

    include<stdio.h>

    include<ctype.h>

    main()

    {

    int i=0;

    char a [81];

    char *p=s;

    clrscr ();

    printf{" Input a string \n");

    for (i=0; i<80; i++)

    {

    s [i] =getchar ( );

    if (s [i]=='\n')

    【 】;

    }

    s[i]=【 】

    printf(" display the string \n");

    while (*p)

    putchar (【 】);

    }


    正确答案:break '/0' *P++
    break '/0' *P++ 解析:第一空:当输入的字符是回车符时,使用break语句跳出for循环,结束输入。第二空:结束输入后,在字符串s最后要加上结束标记符,'\0' 。第三空:最初指针p指向字符串s的首字符,通过P慢逐一指向后面的每个字符,调用putchar()函数输出字符。

  • 第3题:

    以下程序段中,能够通过调用函数fun,使main函数中的指针变量p指向一个合法的整型单元的是

    A.main() { int*p; fun(p); … } int fun(int*p) {int s; p=&s; }

    B.main { int *p; fun(&p); … } int fun(int**p) {int s; *p=&s; }

    C.#include <stdlib.h> main() { int *p; fun(&p); … } int fun(int**p) {*p=(int*)malloc(2); }

    D.#include <stdlib.h> main() { int *p; fun(p); … } int fun(int *p) {p=(int*)malloc(sizeof(int));}


    正确答案:C

  • 第4题:

    请补充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=【 】;

    if(【 】)

    printf ("%4d", i);

    }

    }


    正确答案:i%10 g*g*g==i
    i%10 g*g*g==i 解析:第一空:将一个整数对10求余,就得到这个数的个位数字,并存于变量g中。第二空:如果个位数字的立方等于这个数本身,则将这个数输出。

  • 第5题:

    请补充main 函数,该函数的功能是:先以只写方式打开文件“out99.dat”,再把字符串str中的字符保存到这个磁盘文件中。

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

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

    试题程序:

    include "stdio. h"

    include "conio.h"

    define N 80

    main ()

    {

    FILE *fp;

    int i=0;

    char ch;

    char str[N]="I'm a student!";

    clrscr();

    if ( (fp=fopen (【 】) ) ==NULL)

    {

    printf("cannot open out99. dat\n");

    exit(0);

    }

    while (str[i])

    {

    ch=str[i];

    【 】;

    putchar(ch);

    i++;

    }

    【 】;

    }


    正确答案:“out99.dat”“w” fpnte (chfp) fclose (fp)
    “out99.dat”,“w” fpnte (ch,fp) fclose (fp) 解析:第一空:本题考查对文件操作的掌握。打开一个文件的调用方式是,fp==fopen (文件名,使用文件方式);,题目要求以只写的方式打开文件“out 99.dat”,所以文件使用方式为“w”。第二空;fputc ()函数用于将一个字符写到磁盘文件上去,调用形式为:fputc (要输出的字符,文件指针)。第三空:对一个文件进行操作后,应该关闭它,以防它再被误用。调用形式为:fclose (文件指针);