更多"请编写函数fun,函数的功能是:将3行4列矩阵x乘以4行3列矩阵y,结"的相关试题:
[简答题]请编写函数fun( ),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。
例如x有5门课程的成绩是90.5,72,80,61.5,55,则函数的值为71.80。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
float fun (float *a, int n)
{
}
main ( )
{
float score[30]=(90.5,72,80,61.5,55},
aver;
aver=fun(score, 5);
printf("/nAverage score is: %5.2f
/n",aver);
}
[简答题]请编写函数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");
[简答题]请编写函数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);
[简答题]请编写函数fun( ),该函数的功能是:实现B=A+A’,即把矩阵A加上A的转置,存放在矩阵B中。计算结果在main( )函数中输出。
例如,输入下面矩阵:
1 2 3
4 5 6
7 8 9
其转置矩阵为:
1 4 7
2 5 8
3 6 9
则程序输出:
2 6 10
6 10 14
10 14 18
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#include<conio.h>
void fun (int a[3][3], int b[3][3])
{
}
main ( )
{
int a[3][3]={{1,2,3}, {4,5,6},{7,8,9}},t[3] [3];
int i, j;
clrscr ( );
fun (a,t);
for(i=0; i<3; i++)
{ for (j=0; j<3; j++)
printf ("%7d",t [i] [j] );
printf ("/n");
}
}
[简答题]请编写函数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");
[简答题]请编写函数fun( ),该函数的功能是:移动一维数组中的内容,若数组中有n个整数,要求把下标从p到n-1(p≤n-1)的数组元素平移到数组的前面。
例如,一维数组中的原始内容为1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,p的值为6。移动后,一维数组中的内容应为7,8,9,10,11,12,13,14,15,1,2,3,4,5,6。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
#define N 80
void fun(int *w,int p,int n)
main( )
int a[N]=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15;
int i,p,n=15;
printf("The original data:/n");
for(i=0;i<n;i++)
printf("%3d",a[i]);
printf("/n/nEnter p:");
scanf("%d",&p);
fun(a,p,n);
printf("/nThe data after moving:/n");
for(i=0;i<n;i++)
printf("%3d",a[i]);
printf("/n/n");
[简答题]请编写函数fun( ),该函数的功能是:移动一维数组中的内容,若数组中有n个整数,要求把下标从0到p(p≤n-1)的数组元素平移到数组的最后。
例如,一维数组中的原始内容为1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,p的值为3。移动后,一维数组中的内容应为5,6,7,8,9,10,11,12,13,14,15, 1, 2, 3, 4。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#define N 80
void fun(int *w, int p, int n)
main ( )
int a[N]=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15;
int i, p, n=15;
printf("The original data:/n");
for(i=0;i<n;i++)
printf("%3d",a[i]);
printf("/n/nEnter p: ");
scanf("%d",&p);
fun(a,p,n);
printf("/nThe data after moving:/n");
for(i=0;i<n;i++)
printf("%3d",a[i]);
printf("/n/n");
[简答题]请编写函数fun( ),函数的功能是求出二维数组周边元素之和,作为函数值返回。二维数组中的值在主函数中赋予。
例如:若二维数组中的值为
1 3 5 7 9
2 9 9 9 4
6 9 9 9 8
1 3 5 7 0
则函数值为61。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#define M 4
#define N 5
int fun( int a [M][N])
main( )
int aa[M][N]=1,3,5,7,9,2,9,9,9,4,
6,9,9,9,8,1,3,5,7,0;
int i, j, y;
clrscr( );
printf ("The original data is :/n ");
for(i=0; i<N;i++)
for (j=0; j<N;j++)
printf("%6d ",aa[i][j]);
printf("/n ");
y=fun(aa);
printf("/nThe sun:%d/n ",y);
printf("/n");
[简答题]请编写函数fun( ),该函数的功能是:将M行N列的二维数组中的数据,按行的顺序依次放到一维数组中,一维数组中数据的个数存放在形参n所指的存储单元中。
例如,若二维数组中的数据为:
33 33 33 33
44 44 44 44
55 55 55 55
则一维数组中的内容应该是33 33 33 33 44 44 44 AA, 55 55 55 55
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio. h>
void fun (int (*s)[10], int *b, int *n,
int mm, int nn)
main ( )
int w[10] [10]=33,33,33,33,44,44,
44,44,55,55,55,55, i, j;
int a[100]=0,n=0 ;
printf ("The matrix: /n" );
for (i=0; i<3; i++)
for (j+0; j<4; j++)
printf ("%3d",w[i] [j] );
printf ("/n");
fun (w,a, &n, 3, 4);
printf ("The A array: In");
for(i=0; i<n; i++)
printf ("%3d", a [i] );
printf ("/n/n");
[简答题]请编写函数fun( ),该函数的功能是:删去一维数组中所有相同的数,使之只剩一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。
例如,若一维数组中的数据是:
2 2 2 3 4 4 5 6 6 6 6 7 7 8 9 9 10 10 10
删除后,数组中的内容应该是:
2 3 4 5 6 7 8 9 10。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio. h>
#define N 80
int fun(int a[], int n)
{
}
main ( )
{
int a[N]={ 2,2,2,3,4,4,5,6,6,6,6,7,7,
8,9,9,10,10,10,10}, i, n=20;
printf ("The original data : /n");
for(i=0; i<n; i++)
printf ("%3d", a [i] );
n=fun (a, n);
printf("/n/nThe data after deleted
: /n");
for(i=0; i<n; i++)
printf ("%3d", a [i] );
printf ("/n/n");
}
[简答题]下列程序定义了NXN的二维数组,并在主函数中赋值。请编写函数fun( ),函数的功能是求出数组周边元素的平方和并作为函数值返回给主函数中的s。例如:若a数组中的值为
a=0 1 2 7 9
1 11 21 5 5
2 21 6 11 1
9 7 9 10 2
5 4 1 4 1
则返回主程序后s的值应为310。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#include<conio.h>
#include<stdlib.h>
#define N 5
int fun (int w[][N])
{
}
main( )
{
int a[N][N]={0,1,2,7,9,1,11,21,5,5,2, 21,6,11,1,9,7,9,10,2,5,4,1,4,1};
int i,j;
int s;
clrscr( );
printf("*****The array***+*/n");
for (i=0;i<N;i++)
{ for(j=0;j<N;i++)
{printf("%4d",a[i][j]);}
printf("/n");
}
s=fun(a);
printf("*****THE RESULT*****/n");
printf("The sum is:%d/n",s);
}
[多项选择]编程题
下列程序定义了N×N的二维数组,并在主函数中赋值。请编写函数fun( ),函数的功能是:求出数组周边元素的平方和并作为函数值返回给主函数中的s。例如:若a 数组中的值为
a=0 1 2 7 9
1 11 21 5 5
2 21 6 11 1
9 7 9 10 2
5 4 1 4 1
则返回主程序后s的值应为310。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include
#include
#include
#define N 5
int fun (int w[][N])
{
}
main( )
{
int a[N][N]={0,1,2,7,9,1,11,21,5,5,2,21,6,11,1,9,7,9,10,2,5,4,1,4,1};
int i, j;
int s;
clrscr( );
printf("*****The array*****/n ");
for (i=0; i
[简答题]下列程序定义了N×N的二维数组,并在主函数中赋值。请编写函数fun( ),函数的功能是:求出数组周边元素的平均值并作为函数值返回给主函数中的s。例如:若a数组中的值为
a= 0 1 2 7 9
1 9 7 4 5
2 3 8 3 1
4 5 6 8 2
5 9 1 4 1
则返回土程序后s的值应为3.375。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的仟何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#include<conio.h>
#include<stdlib.h>
#define N 5
double fun (int w[] [N])
{
}
main( )
{
int a[N] [N]={0,1,2,7,9,1,9,7,4,5,2,
3,8,3,1,4,5,6,8,2,5,9,1,4,1};
int i, j;
double s;
clrscr( );
printf("*****The array*****/n ");
for (i=0; i<N; i++)
{ for (j=0;j<N;i++)
{printf("%4d ",a[i] [j]);}
printf("/n ");
}
s=fun(a);
printf("*****THE RESULT*****/n ");
printf("The sum is : %lf/n ",s);
}
[简答题]请编写一个函数fun( ),该函数的功能是:返回给定字符串中大写字母字符的个数。
如字符串"Hello World"中,大写字母的个数为2个。
注意:部分源程序已存在文件PROC5.CPP中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC5.cpp的内容如下:
//PROC5.cpp
#include<iostream>
#include<string>
using namespace std;
int fun(char *str);
int main( )
{
char str[ ]="Chinese Computer World";
cout<<fun(str)<<end;
return 0;
}
int fun(char *str)
{
//**********
}
[简答题]请编写一个函数fun( ),该函数的功能是:返回给定字符串中大写字母字符的个数。
如字符串"Hello World"中,大写字母的个数为2个。
注意:部分源程序已存在文件PROC5.CPP中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC5.cpp的内容如下:
//PROC5.cpp
#include<iostream>
#include<string>
using namespace std;
int fun(char *str);
int main( )
char str[ ]="Chinese Computer World";
cout<<fun(str)<<end;
return 0;
int fun(char *str)
//**********