题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-22 11:23:02

[简答题]请编写一个函数int fun (int nFirst, int nSecond),求两个数的最小公倍数并返回这个值。
注意:部分源程序已存在文件test13_2.cpp中。如输入7和8时,结果是56。
请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。
文件test13_2的内容如下;
#include<iostream.h>
int fun(int nFirst,int nSecond);
void main( )

int nFirst,nSecond;
cout<<"Please input the first one";
cin>>nFirst;
cout<<" Please input the second one";
cin>>nSecond;
cout<<"最小公倍数:"<<fun(nFirst,nSecond)<<endl;

int fun(int nFirst,int nSecond)


更多"请编写一个函数int fun (int nFirst, int nSe"的相关试题:

[简答题]请编写一个函数int fun (int nFirst, int nSecond),求两个数的最小公倍数并返回这个值。 注意:部分源程序已存在文件test13_2.cpp中。如输入7和8时,结果是56。 请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。 文件test13_2的内容如下; #include<iostream.h> int fun(int nFirst,int nSecond); void main( ) { int nFirst,nSecond; cout<<"Please input the first one"; cin>>nFirst; cout<<" Please input the second one"; cin>>nSecond; cout<<"最小公倍数:"<<fun(nFirst,nSecond)<<endl; } int fun(int nFirst,int nSecond) { }
[多项选择]简单应用题 请编写一个函数int fun(int nFirst,int nSecond),求两个数的最小公倍数并返回这个值。 注意:部分源程序已存在文件test13_2.cpp中。如输入7和8时,结果是56。 请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。 文件test13_2的内容如下: #include int fun(int nFirst,int nSecond); void main( ) { int nFirst, nSecond; cout<<"Please input the first one/n"; cin>>nFirst; cout<<"Please input the second one/n"; cin>>nSecond; cout<<"最小公倍数:"<
[简答题]请编写一个函数int fun(int n),其中n为自然数。函数fun( )的功能是求出自然数n(包括n)以内所有素数的和,并返回其值。
注意;部分源程序已存在文件PROC11.cpp中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC11.cpp的内容如下:
//PROC11.cpp
#include<iostream>
using namespace std;
int fun(int n);
int main( )

int number;
cout<<"Enter the number which you want to caculate: /n";
cin>>number;
cout<<"The result is:"<<fun(number)<<end1;
return 0;

int fun(int n)

//* * * * * * * * *

[简答题]请编写函数fun,它的功能是:求任意两个正整数的最小公倍数和最大公约数,最小公倍数放在指针变量bei所指的变量中,最大公约数放在指针变量yue所指的变量中。 注意:部分源程序在文件PROG1.C中。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。 void fun(int m,int n,int*bei,int *yue) {int s=l,i; if(m>n){s=m;m=n;n=S;} for(i=2,s=1;i<m i++) if((m%i=0)&&(n%i=0)) { } *yue=s; *bei=S*m*n; } main( ) {int a,b,beishu,yueshu; chscr( ); printf("please input a,b:");scanf("%d,%d,"&a,&b); fun(a,b,&beishu,&yueshu); printf("a,b beishu:%d/n",beishu); printf("a,b yueshu:%d/n",Yueshu); }
[简答题]请编写一个函数fun(int score [][3],int num),该函数返回有一门成绩以上课程成绩在85分以上,其余课程成绩不低于70分的人数。数组score按行存放num名考生各自的三门期末考试成绩。 注意:部分源程序已存在文件test31_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。 程序输出结果如下: 3 文件test31_2.cpp清单如下: #include <iostream.h> int fun(int score[] [3],int num) { } void main ( ) { int score[4] [3]={{70,89,92},{70,76,93},(80,86,98},{65,73,45}); cout<<fun(score,4)<<end1; }
[简答题]请编写一个函数int fun(int *s,int t,int *k),用来求出数组的最大元素在数组中的下标并存放在k所指的存储单元中。
例如,输入如下整数:
876 675 896 101 301 401 980 431 451 777
则输出结果为6,980。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
int fun(int *s,int t,int *k)


main( )

int a[10]= 876,675,896,101,301,401,
980,431,451,777,k;
clrscr( );
fun(a, 10, &k);
printf("%d, %d/n ", k, a[k]);

[简答题]请编写函数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(int x,int n),该函数返回x的n次幂的值,其中x和n都是非负整数。x的n次幂的计算方法是1与x相乘n次,如x的20次幂的计算为1与x相乘20次, 注意:部分源程序已存在文件test30_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。 如输入3和4,输出结果如下: 3 4 81 文件test30_2.cpp清单如下: #include<iostream.h> double fun(int x, int n) { } void main ( ) { int x,n; cin>>x>>n; cout<<fun(x,n)<<end1; }
[多项选择]编程题 下列程序定义了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 91 11 21 5 52 21 6 11 19 7 9 10 25 4 1 4 1则返回主程序后s的值应为310。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:#include #include#include#define N 5int 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
[简答题]下列程序定义了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);

[多项选择]编程题 请编写一个函数void fun(int m, int k, int xx[]),该函数的功能是:将大于整数m且紧靠m的k个非素数存入所指的数组中。 例如,若输入15,5,则应输出16,18,20,21,22。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include #include void fun(int m, int k, int xx[]) { } main( ) { int m,n,zz[1000]; clrscr( ); printf("/nPlease enter two integers: "); scanf("%d%d",&m,&n); fun(m, n, zz); for(m=0;m

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码