更多"请编写一个函数fun(int x,int n),该函数返回x的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;
}
[简答题]请编写一个函数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 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<<"最小公倍数:"<
[多项选择]编程题
请编写一个函数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
[简答题]请编写一个函数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)
[简答题]请编写一个函数void fun(int m, int k, int xx[]),该函数的功能是将大于整数m且紧靠m的k个非素数存入所指的数组中。
例如,若输入15,5,则应输出16,18,20,21,22。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
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<n;m++)
printf("%d",zz[m]);
printf("/n");
[简答题]请编写一个函数void fun(int m, int k, int xx[]),该函数的功能是:将大于整数m且紧靠m的k个素数存入所指的数组中。
例如,若输入17,5,则应输出19,23,29,3l,37。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <conio.h>
#include <stdio.h>
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=O;m<n;m++)
printf("%d ",zz[m]);
printf("/n ");
}
[简答题]请编写一个函数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)
//* * * * * * * * *
[多项选择]编程题
请编写一个函数int fun(int *s,int t,int *k),用来求出数组的最小元素在数组中的下标并存放在k所指的存储单元中。
例如,输入如下整数:
234 345 753 134 436 458 100 321 135 760
则输出结果为6,100。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include
#include
int fun(int *s,int t,int *k)
{
}
main( )
{
int a[10]={234,345,753,134,436,458,100,321,135,760},k;
clrscr( );
fun(a, 10, &k);
printf("%d, %d/n ", k, a[k]);
}
[简答题]请编写一个函数int fun (int *s,int t,int *k),用来求出数组的最小元素在数组中的下标并存放在k所指的存储单元中。
例如,输入如下整数:
234 345 753 134 436 458 100 321 135 760
则输出结果为6,100。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
int fun(int *s,int t,int *k)
main( )
int a[10]=234,345,753,134,436,458,
100,321,
135,760),k;
clrscr( );
fun(a,10,&k);
printf("%dr %d/n", k, a[k]);