题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-11-25 19:15:27

[简答题]请编写函数fun( ),该函数的功能是:移动一维数组中的内容,若数组中有n个整数,要求把下标从p~n-1(p<n-1)的数组元素平移到数组的前面。
例如,一维数组中的原始内容为1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, P的值为6。移动后,一维数组的内容应为7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
[试题源程序]
#inciude <stdio.h>
#define N 80
void fun(int *w, int p, int n)


main( )

int a[N]=(i, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
int i, P, n=15;
printf("The original data:/n");
for(i=0; i<n; i++)
printf("%3d", a[i]);
printf("/n/nEnter p: ");
scanf("%d", &p);
fun(a, P, n);
printf("/nThe data after moving:/n");
for(i=0; i<n; i++)
printf("%3d", a[i]);
printf("/n/n");

更多"请编写函数fun( ),该函数的功能是:移动一维数组中的内容,若数组中"的相关试题:

[简答题]请编写函数fun( ),该函数的功能是:移动一维数组中的内容,若数组中有n个整数,要求把下标从p~n-1(p<n-1)的数组元素平移到数组的前面。
例如,一维数组中的原始内容为1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, P的值为6。移动后,一维数组的内容应为7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
[试题源程序]
#inciude <stdio.h>
#define N 80
void fun(int *w, int p, int n)


main( )

int a[N]=(i, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
int i, P, n=15;
printf("The original data:/n");
for(i=0; i<n; i++)
printf("%3d", a[i]);
printf("/n/nEnter p: ");
scanf("%d", &p);
fun(a, P, n);
printf("/nThe data after moving:/n");
for(i=0; i<n; i++)
printf("%3d", a[i]);
printf("/n/n");

[简答题]请编写函数fun( ),该函数的功能是:移动一维数组中的内容,若数组中有n个整数,要求把下标从p到n-1(p≤n-1)的数组元素平移到数组的前面。
例如,一维数组中的原始内容为1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,p的值为6。移动后,一维数组中的内容应为7,8,9,10,11,12,13,14,15,1,2,3,4,5,6。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
#define N 80
void fun(int *w,int p,int n)

main( )

int a[N]=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15;
int i,p,n=15;
printf("The original data:/n");
for(i=0;i<n;i++)
printf("%3d",a[i]);
printf("/n/nEnter p:");
scanf("%d",&p);
fun(a,p,n);
printf("/nThe data after moving:/n");
for(i=0;i<n;i++)
printf("%3d",a[i]);
printf("/n/n");

[简答题]请编写函数fun( ),该函数的功能是:移动一维数组中的内容,若数组中有n个整数,要求把下标从0到p(p≤n-1)的数组元素平移到数组的最后。 例如,一维数组中的原始内容为1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,p的值为3。移动后,一维数组中的内容应为5,6,7,8,9,10,11,12,13,14,15, 1, 2, 3, 4。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include <stdio.h> #define N 80 void fun(int *w, int p, int n) { } main ( ) { int a[N]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; int i, p, n=15; printf("The original data:/n"); for(i=0;i<n;i++) printf("%3d",a[i]); printf("/n/nEnter p: "); scanf("%d",&p); fun(a,p,n); printf("/nThe data after moving:/n"); for(i=0;i<n;i++) printf("%3d",a[i]); printf("/n/n"); }
[简答题]请编写函数fun, 函数的功能是: 移动一维数组中的内容; 若数组中有n个整数, 要求把下标从0到p(含p,p小于等于n-1)的数组元素平移到数组的最后。 例如, 一维数组中的原始内容为: 1,2,3,4,5,6,7,8,9,10; p的值为3。移动后, 一维数组中的内容应为: 5,6,7,8,9,10,1,2,3,4。 注意:部分源程序在文件PROG1.C中。请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。 给定源程序: #include #define N 80 void fun(int *w, int p, int n) { } main( ) { int a[N]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; int i,p,n=15; printf("The original data:/n"); for(i=0; i
[简答题]请编写函数fun( ),它的功能是:移动一维数组中的内容,若数组中有n个整数,要求把下标从0到p(含p,p<n-1)的数组元素平移到数组的最后。例如:一维数组中的原始内容为:1,2,3,4,5,6,7,8,9,10;p的值为3。移动后,一维数组中的内容应为: 5,6,7,8,9,10,1,2,3,4。部分源程序在文件PROG1.C中。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
#include<stdiO.h>
#define N 80
void fun(int *w,int p,int n)

main( )
in[ a[N]=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
int i,p,n=15;
printf("The odginal data:/n");
for(i=0;i<n;i++)printf("%3d",a[i]);
printf("/nEnter p:");
scanf("%d",&p);
fun(a,p,n);
printf ("/n The data after moving:/n");
for(i=0;i<n;i++)printf("%3d”,a[i]);

[简答题]请编写函数fun( ),该函数的功能是:将两个两位数的正整数a,b合并形成一个整数放在c中。合并的方式是:将a数的十位和个位数依次放在c数的十位和千位上,b数的十位和个位数依次放在c数的百位和个位上。
例如,当a=45时,b=12,调用到该函数后,c=5142。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#include<conio.h>
void fun(int a ,int b, long *c)


main ( )

int a,b;
long c;
clrscr( );
printf("Input a ,b:");
scanf(,%d%d",&a,&b);
fun(a,b,&c);
printf("The result is :%ld/n",c);

[简答题]请编写函数fun( ),该函数的功能是:删去一维数组中所有相同的数,使之只剩一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。
例如,若一维数组中的数据是:
2 2 2 3 4 4 5 6 6 6 6 7 7 8 9 9 10 10 10
删除后,数组中的内容应该是:
2 3 4 5 6 7 8 9 10。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio. h>
#define N 80
int fun(int a[], int n)

main ( )

int a[N]= 2,2,2,3,4,4,5,6,6,6,6,7,7,
8,9,9,10,10,10,10, i, n=20;
printf ("The original data : /n");
for(i=0; i<n; i++)
printf ("%3d", a [i] );
n=fun (a, n);
printf("/n/nThe data after deleted
: /n");
for(i=0; i<n; i++)
printf ("%3d", a [i] );
printf ("/n/n");

[简答题]请编写函数fun( ),该函数的功能是将M行N列的二维数组中的数据,按列的顺序依次放到一维数组中。
例如:二维数组中的数据为
33333333
44444444
55555555
则一维数组中的内容应是
334455334455334455334455。
注意:部分源程序以存在文件test_2.cpp中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
文件test39_2.cpp的内容如下:
#include<stdio.h>
#include<iostream.h>
void fun(int(*s) [10],int *b, int *n,int mm,int nn)


void main( )

int w[10][10]=33,33,33,33,44,44,44,44,55,55,55,55,i,j;
int a[100]=0, n=0;
cout<<"The matrix:/n"
for(i=0; i<3; i++)

for(j=0; j<4; j++
cout<<w[i] [j];
cout<<endl;

fun(w, a, &n, 3, 4);
cout<<"The A array:/n";
for(i=0; i<n; i++)
cout<<a[i];
cout<<"/n/n";

[简答题]请编写函数fun( ),该函数的功能是:将M行N列的二维数组中的数据,按行的顺序依次放到一维数组中,一维数组中数据的个数存放在形参n所指的存储单元中。 例如,若二维数组中的数据为: 33 33 33 33 44 44 44 44 55 55 55 55 则一维数组中的内容应该是33 33 33 33 44 44 44 AA, 55 55 55 55 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include <stdio. h> void fun (int (*s)[10], int *b, int *n, int mm, int nn) { } main ( ) { int w[10] [10]={{33,33,33,33},{44,44, 44,44},{55,55,55,55}}, i, j; int a[100]={0},n=0 ; printf ("The matrix: /n" ); for (i=0; i<3; i++) {for (j+0; j<4; j++) printf ("%3d",w[i] [j] ); printf ("/n"); } fun (w,a, &n, 3, 4); printf ("The A array: In"); for(i=0; i<n; i++) printf ("%3d", a [i] ); printf ("/n/n"); }
[简答题]请编写一个函数fun,它的功能是:将一个数字字符串转换为一个整数(不得调用C语言提供的将字符串转换为整数的函数)。例如,若输入字符串"-1234",则函数把它转换为整数值 -1234。函数fun中给出的语句仅供参考。 注意: 部分源程序存在文件PROG1.C文件中。 请勿改动主函数main和其它函数中的任何内容, 仅在函数fun的花括号中填入你编写的若干语句。 给定源程序: #include #include long fun ( char *p) {int i, len, t; /* len为串长,t为正负标识 */ long x=0; len=strlen(p); if(p[0]==’-’) { t=-1; len--; p++; } else t=1; /* 以下完成数字字符串转换为一个数字 */ return x*t; } main( ) /* 主函数 */ { char s[6]; long n; printf("Enter a string:/n") ; gets(s); n = fun(s); printf("%ld/n",n); NONO ( ); } NONO ( ) {/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */ FILE *fp, *wf ; int i ; char s[20] ; long n ; fp = fopen("c://test//in.dat","r") ; wf = fopen("c://test//out.dat","w") ; for(i = 0 ; i < 10 ; i++) { fscanf(fp, "%s", s) ; n = fun(s); fprintf(wf, "%ld/n", n) ; } fclose(fp) ; fclose(wf) ; }
[简答题]请编写一个函数fun( ),它的功能是将一个数字字符串转换为一个整数(不得调用C语言提供的将字符串转为整数的函数)。 例如,若输入字符串“-1234”,则函数把它转换为整数值 -1234。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include <stdio.h> #include <string.h> long fun(char *p) { } main ( ) { char s[6]; long n; printf("Enter a string:/n"); gets(s); n=fun(s); printf("%ld/n",n); }
[简答题]请编写函数fun( ),该函数的功能是:移动字符串中的内容,移动的规则是把第1到第m个字符,平移到字符串的最后,把第m+1到最后的字符移到字符串的前部。 例如,字符串中原有的内容为ABCDEFGHIJK,m的值为 3,移动后,字符串中的内容应该是DEFGHIJKABC。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include <stdio. h> #include <string.h> #define N 80 void fun (char *w, int m) { } main ( ) { char a[N]= "ABCDEFGHIJK"; int m; printf ("The origina string : /n"); puts (a); printf("/n/nEnter m: "); scanf ("%d", &m); fun (a, m); printf (" /nThe string after moving : /n"); puts (a); printf ("/n/n"); }
[简答题]请编写函数fun,其功能是将两个两位数的正整数a、b合并形成一个整数放在c中。合并的方式是:将a数的十位和个位数依次放在c数个位和十位上,b数的十位和个位数依次放在c数的百位和千位上。
例如,当a=16,b=35,调用该函数后,c=5361。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
void fun(int a,int b/long*c)

main( )

int a,b;
long c;
clrscr( );
printf("Input a,b;");
scanf("%d%d",&a,&b);
fun(a,b,&c);
printf("The result is:%ld/n",c);

[简答题]请编写函数fun, 函数的功能是: 删去一维数组中所有相同的数, 使之只剩一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。 例如, 一维数组中的数据是: 2 2 2 3 4 4 5 6 6 6 6 7 7 8 9 9 10 10 10。 删除后,数组中的内容应该是: 2 3 4 5 6 7 8 9 10。 注意:部分源程序在文件PROG1.C中。 请勿改动主函数main和其它函数中的任何内容, 仅在函数fun的花括号中填入你编写的若干语句。 给定源程序: #include #define N 80 int fun(int a[], int n) { } main( ) { int a[N]={2,2,2,3,4,4,5,6,6,6,6,7,7,8,9,9,10,10,10,10},i,n=20; printf("The original data :/n"); for(i=0; i
[简答题]请编写函数fun( ),该函数的功能是判断字符串是否为回文,若是则函数返回1,主函数中输出YES:否则返回0,主函数中输出NO。回文是指顺读和倒读都一样的字符串。
例如:字符串LEVEL是回文,而字符串123312就不是回文。
注意;部分源程序已存在文件test26_.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。
文件test26_2.cpp的内容如下:
#include<iostream.h>
#include<stdio.h>
#define N 80
int fun(char*str)


void main( )
char s[N];
cout<<"Enter a string:"<<endl;
getss);
cout<<"/n/n";
puts(s);
if(fun(s))
cout<<"YES/n";
else
cout<<"NO/n";

[简答题]简单应用题 请编写函数fun( ),该函数的功能是判断字符串是否为回文,若是则函数返回1,主函数中输出YES;否则返回0,主函数中输出NO。回文是指顺读和倒读都一样的字符串。 例如:字符串LEVEL是回文,而字符串123312就不是回文。 注意:部分源程序已存在文件kt11_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。 文件kt11_2.cpp的内容如下: #include #include #defineN80 intfun(char*str) { } voidmain( ) { chars[N]; cout<<"Enterastring:"<
[简答题]请编写函数fun( ),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。
例如x有5门课程的成绩是90.5,72,80,61.5,55,则函数的值为71.80。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
float fun (float *a, int n)


main ( )

float score[30]=(90.5,72,80,61.5,55,
aver;
aver=fun(score, 5);
printf("/nAverage score is: %5.2f
/n",aver);

我来回答:

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

订单号:

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