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

[填空题]以下程序的功能是:删去一维数组中所有相同的数,使相同的数只剩一个。数组中的数已按由小到大的顺序排列,函数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。请填空。
#include <stdio.h>
#define N 80
int fun(int a[], int n)
int i,j=1;
for(i=1;i<n;i++)
if(a[j-1] a[i]) a[j++]=a[i];
;

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

更多"以下程序的功能是:删去一维数组中所有相同的数,使相同的数只剩一个。数组"的相关试题:

[填空题]以下程序的功能是:删去一维数组中所有相同的数,使相同的数只剩一个。数组中的数已按由小到大的顺序排列,函数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。请填空。 #include <stdio.h> #define N 80 int fun(int a[], int n) { int i,j=1; for(i=1;i<n;i++) if(a[j-1] 【19】 a[i]) a[j++]=a[i]; 【20】 ; } main( ) { int a[N]={2,2,2,3,4,4,5,6,6,6,6,7,7,8,9,9,10,10,10},i,n=19; printf("The original data :/n"); for(i=0;i<n;i++) printf("%3d",a[i]); n=fun(a,n); printf("/nThe data after deleted :/n"); for(i=0; i<n; i++) printf("%3d",a[i]); printf("/n/n"); }
[填空题]以下程序的功能是:删去一维数组中所有相同的数,使之只剩一个。数组中的数已按由小到大的顺序排列,函数返回删除后数组中数据的个数。 例如,若一维数组中的数据是: 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。 请填空。 #include<stdio.h> #define N 80 intfun(int a[],int n) {int i,j=1; for(i=1;i<n;i++) if(a[j-1] [8] a[i]) a[j++]=a[i]; [9] ; } main( ) {int a[N]={2,2,2,3,4,4,5,6,6,6,6,7,7,8,9,9,10,10,10},i,n=19; printf("The original data:/n"); for(i=0;i<n;i++)printf("%3d",a[i]); n=fun(a,n); printf("/nThe data after deleted:/n"); for(i=0;i<n;i++)printf("%3d",a[i]);printf("/n/n"); }
[简答题]下列给定程序中,函数fun的功能是:用冒泡法对6个字符串按由小到大的顺序排列。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
#define MAXLINE 20
fun(char*pstr[6])

lnt i,j;
char *p;
for(i=O;i<5;i++)

/********found********/
for(j=i+l,j<6,j++)

if(strcmp(*(pstr+i)*(pstr+j))>0)

P=*(psfr+i);
/********found********/
*(pstr+i)=pstr+j;
*(pstr+j)=p;




void main( )

int i;
char*pstr[6],str[6][MAXLINE];
system("CLS");
for(i=O;i<6;i++)
pstr[i]=str[i];
printf("/nEnter 6 string(1 string at eachline):/n");
for(i=0;i<6;i++)
scanf("%s",pstr[i]);
fun(pstr);
printf("The strings after sorting:/n");
for(i=O;i<6;i++)
printf("%s/n"pstr[i]);

[简答题]给定一个函数,其函数功能为:使10个整数按由小到大的顺序排列。在主函数中输入10个数,并输出结果。使用VC6打开考生文件夹下的工程RevProj5。此工程包含一个源程序文件RevMain5.cpp,该程序实现上述功能。但此程序运行有问题。请找出错误的地方,改正后将此程序调试正确。
注意:不得删行或增行,也不得更改程序结构。
文件RevMain5.cpp中的程序清单如下:
//RevMain5.cpp
#include<iostream>
#include<iomanip>
using namespace std;
int main( )

void sort(int array[],int n);
int data[10],*p,i;
cout<<"Input 10 numbers/n";
for (i=0; i<10; i++)
cin>>data [i];
cout<<"the origined array is:";
for (p=data;p<data+10;p++)

if((p-&data[0]) %5==0)
cout<<" /n";
cout<<setw (5) <<*p;

sort (data, 10);
cout<<"/n the present array is:";
for(p=data;p〈data+10;p++)

if((p-&data[0])%5==0) cout<<"/n";
cout<<setw (5)<<*p;


void sort(int array[],int n)

/* * * * * * * * *found * * * * * * * * * */
for(p1=array;p1<array+(n-1) ;p1++)

for (p2=p1+1 ;p2<array+n;p
[单项选择]一个三位数能同时被4、5、7整除,这样的三位数按由小到大的顺序排列成一列,中间的一个是( )。
A. 140
B. 980
C. 560
D. 650
[简答题]请编写函数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,1,1,2,2,2,3, 4,4,5,5,6,6,7,7,8,9,9,10,10。 删除后,数组中的内容应该是:1,2,3,4,5,6,7, 8,9,10。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #define N 80 int fun(int a[],int n) { int i, t,j=0; t=a[0]; for(i=1;i<n;i++) if( 【1】 ) ; else { 【2】 ; t=a[i]; } a[j++]=t; return j; } main( ) { int a[N]={1,1,2,2,2,3,4,4,5,5,6,6,6, 7,7,8,9,9,10,10},i,n=20; printf("The original data:/n"); for(i=0; i<n; i++) printf("%4d",a[i]); n=fun(a,n); printf("/n/nThe data after deleted ; /n"); for (i=0;i<n;i++) printf("%4d",a[i]); printf("/n"); }
[简答题]请编写函数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");

[填空题]以下程序的功能是将字符串s中所有小写字母’a’删去,请填空。
#include<stdio.h>
main( )
char s[]="absuWWUDJFKFLaaakdK";
int i,j;
for(i=j=0;s[i]!=’/0’;i++)
if( )
s[j++]=s[i];
s[j]=’/0’;
printf("%s",s);

[填空题]以下程序的功能是:将一维数组A中的100个元素分别赋给二维数组B的每个元素并打印出来,要求把A(1)到A(10)依次赋给B(1,1)到B(1,10),把A(11)到A(20)依次赋给B(2,1)到B(2,10),……,把A(91)到A(100)依次赋给B(10,1)到B(10,10)。请填空。
Option Base 1
Private Sub Form_Click( )
  Dim i As Integer,j As Integer
  Dim A(1 To 100)As Integer
  Dim B(1 To 10,1 To 10)As Integer
  For i=1 To 100
    A(i)=Int(Rnd*100)
  Next i
For i=1 To (9)
     For j=1 To 10
       B(i,j)= (10)
       Print B(i,j);
     Next j
     Print
   Next i
End Sub

我来回答:

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

订单号:

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