程序中对fun函数有如下说明 void*fun(); 此说明的含义是
A.fun函数无返回值
B.fun函数的返回值可以是任意的数据类型
C.fun函数的返回值是无值型的指针类型
D.指针fun指向一个函数、该函数无返回值
A.fun函数无返回值
B.fun函数的返回值可以是任意的数据类型
C.fun函数的返回值是无值型的指针类型
D.指针fun指向一个函数、该函数无返回值
第1题
请编写函数void fun(int x, int pp[], int *n),它的功能是:求出能整除x且不是偶数的各整数,并按从小到大的顺序放在即所指的数组中,这些除数的个数通过形参n返回。
例如,若x中的值为30,则有4个数符合要求,它们是1, 3,5,15。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <conio.h>
include <stdio.h>
void fun (int x, int pp[], int *n)
{
}
main()
{
int x,aa[1000], n, i ;
clrscr();
printf("\nPlease enter an integer
number : \n ") ;
scanf ("%d", &x) ;
fun (x, aa, &n) ;
for (i=0 ; i<n ; i++)
printf ("%d ", aa [i]);
printf ("\n ") ;
}
第2题
请编写函数fun(),该函数的功能是:将两个两位数的正整数a,b合并形成一个整数放在c中。合并的方式是:将a数的十位和个位数依次放在c数的十位和千位上,b数的十位和个位数依次放在c数的百位和个位上。
例如,当a=45时,b=12,调用到该函数后,c=5142。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <stdio.h>
include<conio.h>
void fun(int a ,int b, long *c)
{
}
main ()
{
int a,b;
long c;
clrscr();
printf("Input a ,b:");
scanf(,%d%d",&a,&b);
fun(a,b,&c);
printf("The result is :%ld\n",c);
}
第3题
请编写函数fun(),其功能是:将s所指字符串中下标为偶数的字符删除,串中剩余字符形成的新串放在t所指数组中。
例如,当s所指字符串中的内容为ABCDEFGHIJK,则在t所指数组中的内容应是BDFHJ。
注意:部分源程序给出如下。
请勿改动主函数main口其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio. h>
include<stdio .h>
include<string.h>
void fun(char *s,char t[])
{
}
main ()
char s[l00] ,t[l00];
clrscr ();
printf("%nPlease enter string S: ");
scanf("%s ",s);
fun(s,t);
prlntf("\nThe result is:%s\n ",t);
}
第4题
请编写函数fun(),该函数的功能是:移动字符串中的内容,移动的规则是把第1到第m个字符,平移到字符串的最后,把第m+1到最后的字符移到字符串的前部。
例如,字符串中原有的内容为ABCDEFGHIJK,m的值为 3,移动后,字符串中的内容应该是DEFGHIJKABC。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <stdio. h>
include <string.h>
define N 80
void fun (char *w, int m)
{
}
main ()
{
char a[N]= "ABCDEFGHIJK";
int m;
printf ("The origina string : \n");
puts (a);
printf("\n\nEnter m: ");
scanf ("%d", &m);
fun (a, m);
printf (" \nThe string after moving : \n");
puts (a);
printf ("\n\n");
}
第5题
请编写函数fun(),该函数的功能是:将M行N列的二维数组中的字符数据,按列的顺序依次放到一个字符串中。
例如,若二维数组中的数据为:
W WWW
S S S S
H H H H
则字符串中的内容应是WSHWSHWSHWSH。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<stdio.h>
define M 3
define N 4
void fun(char (*s)[N],char *b)
{
}
main()
{
char a[100],w[M][N]={{ 'W', 'W', 'W', 'W'},
{'S', 'S', 'S', 'S'},{'H', 'H', 'H', 'H'}};
int i,j;
printf("The matrix:\n");
for(i=0;i<M;i++)
{ for(j=0;j<N;j++)
printf("%3c",w[i][j]);
printf("\n");
}
fun(w,a);
printf("The A string:In");
puts(a);
printf("\n\n");
}
第6题
阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。
[说明1]
函数void fun(char*w,char x,int*n)用来在w数组中插入x,w数组中的数已按由小到大顺序存放,n指存储单元中存放数组中数据的个数,插入后数组中的数仍有序。
[C函数1]
void fun(char*W,char x,int*n)
{ int i,P;
p=0;
w[*n]=x;
while(x>w[p]) (1) ;
for(i=*n,i>p;i--)w[i]=(2);
w[p]=x;
++*n;
}
[说明2]
函数void revstr(char*s)将字符串s逆置。例如:字符串“abcde”,经过逆置后变为“edcba”。
[C函数2]
void revstr(char*s)
{ char*p,c;
if(s==NULL)return;
p=(3); /*p指向字符串s的最后一个有效字符*/
while(s<p){ /*交换并移动指针*/
C=*s;
(4)=*p;
(5)=c;
}
}
第7题
请补充函数fun(),该函数的功能是:分类统计一个字符串中元音字母和其他字符的个数(不区分大小写)。
例如,输入aeiouAOUpqn,结果为A∶2 E∶1 1∶1 O∶2 U∶2 Other∶4。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdiO.h>
include<conio.h>
define N 100
void fun(char *str,int bb[ ])
{
char *p=str;
int i=0;
for(i=0;i<6;i++)
【 】;
while(*p)
{
switch(*p)
{
case 'A':
case 'a':bb[0]++;break;
case 'E':
case 'e':bb[1]++;break;
case 'I':
case 'i':bb[2]++;break;
case 'O':
case 'o':bb[3]++;break;
case 'U':
case 'u':bb[4]++;break;
default:【 】;
}
【 】
}
}
main()
{
char str[N),ss[6]="AEIOU";
int i;
int bb[6];
clrscr();
printf("Input a string:\n");
gets(str);
printf("the string is:\n");
puts(str);
fun(str,bb);
for(i=0;i<5;i++)
printf("\n%c:%d",ss[i],bb[i]);
printf("\nother:%d",bb[i]);
}
第8题
A.fun函数无返回值
B.fun函数不带参数
C.fun函数的返回值可以是任意的数据类型
D.fun函数的返回值是无值型的指针类型
第9题
有以下函数定义: void fun(int n,double x){......} 变量都已正确定义并赋值,则对函数fun正确调用语句是()。
A.fun(int y, double m)
B.k=fun(10,12.5)
C.fun(x,n)
D.void fun(n,x)
第10题
请补充函数fun(),该函数的功能是:按行统计N×N维矩阵元素中的最大值(均为整数),并把这些值按从小到大的顺序保存在数组b中。矩阵的维数在主函数中输入,并赋予随机数。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio.h>
include<conio.h>
include<stdlib.h>
define N 20
void fun(【 】)
{
int i j;
int t;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(【 】)
b[i]=a[i][j];
for(i=0;i<n;i++)
{
for(j=0;i<n;j++)
if(【 】)
{
t=b[i];
b[i]=b[j];
b[j]=t;
}
}
}
main()
{
int a[N][N];
int b[N];
int n;
int i,j;
clrscr();
printf("*****Input the dimension of array N*****\n");
scanf("%d",&n);
printf("*****The array *****\n");
for(i=0;i<n;i++)
{
for(j=0;i<n;j++)
{
a[i][j]=rand()%20;
while(a[i][j]==0)
a[i][j]=rand()%30;
printf("%4d",a[i][j]);
}
printf(”\n\n”);
}
for(i=0;i<n;i++)
b[i]=0;
fun(a,b,n);
printf("***** THE RESULT *****\n");
for(i=0;i<n;i++)
printf(“%d”,b[i]);
}