更多"请编写一个函数char *fun(char *s,int n)。函数f"的相关试题:
[简答题]请编写一个函数char *fun(char *s,int n)。函数fun( )的功能是将字符串s中的字符“循环左移”n位。例如,输入“ABCDE”,则循环左移2位应输出“CDEAB”,输入“1234567”,循环左移3位应输出“4567123”。
注意:部分源程序已存在文件PROC13.cpp中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun( )的花括号中填写若干语句。
文件PROC13.cpp的内容如下:
//PROC13.cpp
#include <iostream>
#include <string>
using namespace std;
char *fun(char *s,int n);
int main( )
{
char str[81];
int n;
cout<<"Enter a string(less than 80 char)/n”;
cin>>str;
cout<<"/n Enter n:";
cin>>n;
if(n>strlen(str))
{
cout<<"/n Data overflow";
return 0;
}
cout<<"The result is: "<<fun(str,n)<<end1;
return 0;
}
char *fun(char*s,int n)
{
//* * * * * *
}
[简答题]简单应用题
请编写一个函数void fun(char ss[]),该函数将字符串ss翻转,如ss为"123abc"则翻转后为"cba321"。注意:用数组方式及for循环来实现该函数。
注意:部分源程序已存在文件test16_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。
文件test16_2.cpp的内容如下:
#include
#include
void fun(char ss[]);
void main( )
{
char s[80];
cout<<"请输入字符串:";
cin>>s;
fun(s);
cout<<"逆序后的字符串:"<
[简答题]请编写一个函数void fun(char ss[]),该函数将字符串ss翻转,如ss为“123abc”则翻转后为“cba321”。注意:用数组方式及for循环来实现该函数。
注意:部分源程序已存在文件test16_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。
文件test16_2.cpp 的内容如下:
#include<iostream.h>
#include<string.h>
void fun (char ss[]);
void main ( )
char s[80];
cout<< "请输入字符串: ";
cin>>s;
fun(s);
cout<< "逆序后的字符串: "<< s<<end1;
void fun(char ss[])
[简答题]请编写一个函数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)
//* * * * * * * * *
[简答题]请编写一个函数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 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 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)