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

[简答题]请编写两个函数int sum_of_powers(int k,int n),powers(int m,int n),求1~6的k次方的和,sum_of_powers中参数k和n分别表示k次方和所求数列中最大的一个自然数,最后返回所求值,powers中参数m和n分别表示m为底数n为指数,最后返回所求值。要求使用for循环和函数嵌套(int sum_of_powers中调用powers)实现算法。输出结果如下:
sum of 4 powers of intergers from 1 to 6=2275
注意:部分源程序已存在文件test25_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数sum_of_powers和powers的花括号中填写若干语句。
文件test25_2.cpp的内容如下:
#include<iostream.h>
const int k(4);
const int n(6);
int sum_of_powers(int k,int n),powers(int m,int n);
void main( )

cout<<"sum of "<<k<<" powers Of intergers from 1 to "<<n<<"=";
cout<<sum_of_powers(k,n)<<endl;

int sum_of_powers(int k,int n)


int powers(int m, int n)


更多"请编写两个函数int sum_of_powers(int k,int "的相关试题:

[多项选择]简单应用题 请编写一个函数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 sort(int &x,&y)和void sort(int x,int y,int z),实现对2个和3个元素的排序并在屏幕上输出排序结果 (数字之间使用跳格)。
注意:部分源程序已存放在文件test2_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数的花括号中填写若干语句。
输出结果如下:
3 4
2 3 4
文件test2_2.cpp的内容如下:
#include<iostream.h>
void sort(int &x,int &y)

/**1**/

void sort(int x,int y,int z)

/**2**/

void main( )

int a=4,b=3,c=2;
sort(a,b);
sort(a,b,C);

[简答题]请编写一个函数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 sort(int &x, &y)和void sort(int x,int y,int z),实现对2个和3个元素的排序并在屏幕上输出排序结果(数字之间使用跳格)。 注意:部分源程序已存放在文件test2_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数的花括号中填写若干语句。 输出结果如下: 3 4 2 3 4 文件test2_2.cpp的内容如下: #include void sort(int &x,int &y) { /**1**/ } void sort(int x,int y,int z) { /**2**/ } void main( ) { int a=4,b=3,c=2; sort(a,b); sort(a,b,c); }
[简答题]请编写一个函数int compare(char *s,char *t)), 该函数的功能是对两个字符串进行比较。当s所指字符串和t所指字符串相等时,返回值为0;当s所指字符串大于是t指字符串时,返回值大于0;当s所指字符串小于t所指字符串时,返回值小于0。
注意:部分源程序已存在文件PROC8.cpp中。
文件PROC8.cpp的内容如下:
//PROC8.cpp
#include <iostream>
#include <string>
using namespace std;
int compare(char *s,char *t)

//* * * * * * * * *

int main ( )

char str1[100],str2[100];
int result;
cout<<"Input the first string/n";
cin>>str1;
cout<<"Input the second string/n";
cin>>str2;
result=compare(str1,str2);
if (result==0)
cout<<"string1=string2 ! /n";
else if (result>0)
cout<<"string1>string2 ! /n";
else
cout<<"string1<string2 ! /n";
return 0;

[多项选择]简单应用题 请编写一个函数void swap(int *x,int *y),用来交换两个数的值。 注意:部分源程序已存在文件test14_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数swap的花括号中填写若干语句。 文件test14_2.cpp的内容如下: #include void swap(int *x,int *y); void main( ) { int a=1,b=3; swap(&a,&b); cout<<"a="<查看答案
[简答题]请编写一个函数void swap(int *x,int*y),用来交换两个数的值。 注意:部分源程序已存在文件test14_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数swap的花括号中填写若干语句。 文件test14_2.cpp的内容如下: #include<iostream.h> void swap(int *x,int*y); void main( ) { int a=1,b=3; swap(&a,&b); cout<<"a="<<a<<" "<<"b="<<b<<endl; } void swap(int *x,int *y) { }
[简答题]请编写一个函数void swap(int *x,int*y),用来交换两个数的值。
注意:部分源程序已存在文件test14_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数swap的花括号中填写若干语句。
文件test14_2.cpp的内容如下:
#include<iostream.h>
void swap(int *x,int*y);
void main( )

int a=1,b=3;
swap(&a,&b);
cout<<"a="<<a<<" "<<"b="<<b<<endl;

void swap(int *x,int *y)


[简答题]请编写一个函数printdate(int year,int month,int day),该函数实现将输入的3个数字转换成英语数字纪年输出的功能,如输入March9,1978,则输出1978 3 9。注意:使用switch结构实现该函数的基本功能并应该能够判断错误的输入。部分源程序已存在文件test40_2.cpp中。请勿修改主函数main和其他函数中的任何内容,仅在函数printdate的花括号中填写若干语句。
源程序文件rest40_2.cpp清单如下:
#include<iostream.h>
void printdate(int year, int month, int day)


void main( )

printdate(1978,3,9);

我来回答:

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

订单号:

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