题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-01-21 05:09:04

[简答题]

改错题:以下程序的功能是:把键盘输入的10个整数显示在屏幕上。
#include<stdio.h>
main( )
{ int a[10],i;
for(i=0;i<10;++i)
scanf("%d",a[i]);
for(i=0;i<10;++i)
printf("%d",a[i]);
}


更多"改错题:以下程序的功能是:把键盘输入的10个整数显示在屏幕上。 #in"的相关试题:

[简答题]

改错题:以下程序的功能是:求30个学生某门课程的平均成绩。
#include<stdio.h>
main( )
{ int n=30,i=0,t;
float aver=0;
while(i<n)
{scanf("%d",&t); aver=aver+t;
}
aver=aver/n;
printf("平均成绩为:%5.1f/n",aver);
}


[简答题]改错题 【题目】 本程序的功能是找出给定范围内因子个数最多的整数.程序界面参加下图 (本程序界面由1个ListBox、1个Label、1个TextBox和1个CommandButton组成,所有对象均采用缺省名) Option Explicit Option Base 1 Private Sub Command1_Click( ) Dim i As integer,j as integer,m as integer,n as integer Dim s As String, mx as integer Dim yz( ) as integer,c( ) as integer m=15: n=35 Redim c(m:n) For i=m to n s=i & ":" Call qyz(i,yz) c(i)=Ubound(yz) For j=1 to Ubound(yz) s=s & yz(j) &"," next j s=Left(s,len(s)-1) List1.Additem s Next i mx=c(1) For i=m to n if c(i)>mx then mx=c(i) Next i For i=m to n if c(i)=mx then Text1.text=text1.text & i & "," Next i Text1.Text=Left(Text1.text,Len(text1.text)-1) End Sub Private Sub qyz(Byval n as integer,yz( ) as integer) Dim i as integer,p as integer For i=1 to n-1 if n mod i=0 then p=p+1 Redim yz(p) yz(p)=i End if
[简答题]改错题(20分) 【题目】 以下程序的功能是:根据字符串str中是否包含子串substr,决定如何将字符串str1插入到str的不同位置。插入方法是:如果str中包含子串substr,则将str1插入到str中首次出现的子串substr之后;否则,插入到str的尾部。 正确程序的输出如下: 原字符串:aabcd12345 子字符串:abcd 插入字符串:ABC 新字符串:aabcdABC12345 含有错误的源程序如下: #include #include char *find(char *str,char *substr) { unsigned lent=strlen(str); for(char *p1=str,*p2=substr;strlen(p1)>=len;p1++){ for(unsigned i=0;ilen) return p1+len; } return 0; } char *insert(char *str,char *substr,char *str1) { char p=find(str,substr); if(p) strcat(str,str1); else{ char *tmp=new char[strlen(str)+strlen(str1)+1]; strcpy(tmp,str1) strcat(tmp,p); strcpy(p,tmp); delete []tmp; } return str; } void main( ) { char *str=new char[80],substr[]="abcd",str1[]="ABC"; strcpy(str,"aabcdl2345"); ’ cout<<"原字符串:"<<
[简答题]

改错题
【题目】
以下程序中,函数fun(int m, int fac[], int &p)的功能是:计算参数m(m>2)的所有因子,将这些因子按从小到大的顺序依次存放在数组fac中,将因子个数存放在参数p中,并返回所有因子之和。
正确程序的输入/输出结果如下(下划线部分为键盘输入):
输入一个整数:24
24的所有因子之和为:60
24的各因子为:1 2 3 4 6 8 12 24
含有错误的源程序如下:
1 #include
2 #include
3 int fun(int,int[],int);
4 void main(void)
5 {
6 int n,f[100],p;
7 cout<<"输入一个整数:";
8 cin>>n;
9 cout< 10 cout< 11 for(int i=0;i 12 cout< 13 cout< 14 }
15 int fun(int m,int fac[],int &p)
16 {
17 int i,s;
18 fac[0]=p=1;
19 for(s=1,i=2;i<=sqrt(m);i++){
20 if(m%i=0){
21 fac[p++]=i;
22 s+=i;
23 }
24 }
25 fac[p]=m;
26 s+=m;
27 return fac;
28 }
【要求】
1.打开T盘中myfa.txt文件,将其文本拷贝到文件myfa.cpp中(或将上述程序录入到文件myfa.cpp中),根据题目要求及程序中语句之间的逻辑关系对程序中的错误进行修改。程序中的注解可以不输入

[简答题]改错题(20分) 【题目】 以下程序的功能是:判断一个已排序的整型数组中是否存在元素值与其下标值相等(下标从0开始)的元素。如果存在,则输出其中一个该类元素的值(可能存在多个满足条件的元素) 正确程序的输出如下: 第3个元素值与其下标值相等 含有错误的源程序如下: #include int index_search(int x[n],int n) { int first=0; int last=n-1; int middle,index; index=-1; while(first<=last){ middle=(first+last)/2; if(x[middle]=middle){ index=middle; break; } else if(x[middle]>middle) last=middle-1; else first=middle+1; } return index; } void main( ) { int a[]={-1,0,1,3,8}; int result=index_search(a,sizeof(a)); if(result==-1) cout<<"第"<
[填空题]若从键盘输入70,则以下程序输出的结果是【 】。    #include<iostream.h>    void main( )    { int a;cin>>a;      if(a>50) cout<<a;      if(a>40)cout<<a;      if(a>30)cout<<a}
[填空题]若从键盘输入70,则以下程序输出的结果是 【8】 。    #include<iostream.h>    void main( )    { int a;cin>>a;      if(a>50) cout<<a;      if(a>40)cout<<a;      if(a>30)cout<<a}
[简答题]改错题【程序功能】 函数fun的功能是将str所指向的一行包含若干单词的文本(单词之间用空格隔开)依次拆分成长度不超过20个字符的若干文本行,单词不跨行,且使拆分出的行数最少,再将拆分出的每行字符以字符串的形式存储到page指向的二维数组的一行中,函数返回拆分出的行数 【测试数据与运行结果】 测试数据:A great discovery solves a greate problem. 屏幕输出: A great disconvery solves a great problem【含有错误的源程序】以下源程序已保存在T盘myf1.c文件内,考生可直接打开该文件调试程序#include #include #include int fun(char str[],char pag[][]){int i,k=0,j,flag=1; while(*str && flag) {if(strlen(str)<20) {pag[k]=str; flag=0; } else {i=20; while(str[i]!=’ ’) i--; for(j=0;j
[填空题]以下程序运行时若从键盘输入:10 20 30<回车>,输出结果是 【10】
# include<stdio.h>
main( )
int i=0,j=0,k=0;
scanf("%d% *d%d",&i,&j,&k);printf("%d %d %d/n",i,j,k);

[简答题]

改错题
【程序功能】
统计一组单词(本题中含2个单词)中的每个单词在一篇文章中各自出现的次数,单词中的字母字符区分大小写。
【测试数据与运行结果】
测试数据:
文章正文: The Olympic Games will be held just outside the capital and the whole area will be called ’Olympic City’.
被统计的一组单词:Olympic, will
屏幕输出:Olympic:2
wi11:2
【含有错误的源程序】
以下源程序已保存在T盘myf1.c文件内,考生可直接打开该文件调试程序。
1 #include< stdio.h>
2 #include< conio.h>
3 #include< string.h>
4 #include< ctype.h>
5 void count( char str[] ,char substr[][10] ,int ct[],int n)
6 {
7 int i,j,k =0,m =0;
8 char t[];
9 for(i=0;str[i];i++)
10 {
11 for(j=i;isalpha(str[j]);i++)
12 {
13 t[m]=str[j];
14 j++;m++;
15 }
16 t[m]=’/0’;
17 for(k=0;k)
18 if( t == substr[k])
19 ct[k]++;
20 m=0;
21 }
22 }
23 int main( )
24 {
25 char line[]="The Olympic Games will be held just outside the capital and the

[填空题]以下程序运行时若从键盘输入:10 20 30<回车>。输出结果是______。
#include <stdio.h>
main( )

int i=0,j=0,k=0;
scanf("%d%*d%d",&i,&j,&k);
printf("%d %d %d/n",i,j,k);

[填空题]在以下程序运行时若从键盘输入:10 20 30<回车>。输出结果是______。
#include<stdio.h>
main( )
int i=0,j=0,k=0;
scanf("%d%*d%d",&i,&j,&k);
printf("%d%d%d/n",i,j,k);

我来回答:

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

订单号:

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