更多"请编写两个函数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);