更多"【说明】
下面的程序按照以下规则输出给定名词的复数形式。
a."的相关试题:
[填空题]【说明】
下面一段程序从给定的数组b中找出值最小的元素,并输出该元素的数组下标、内存地址minaddr以及元素值本身。函数findmin负责在给定的数组中查找最小值,并返回最小值所在的内存地址,函数有三个参数:array是所要处理的数组;size是数组的大小;index负责从函数返回具有最大值的元素在数组中的数组下标。请填充空白,使其成为一个合乎要求的完整程序。
【程序】
//程序开始
#include<iostream.h>
int *findmin(int *array, int size, int &index);
void main( )
{
/****** 变量定义部分 ***********/
int b[10] = {34, 34, 23, 89, 1, 2, 13, 42, 5, 54};
(1) ;
int idx;
/******* 寻找最小值 ************/
minaddr = findmin(b, sizeof(b)/sizeof(int), idx);
/******* 输出最小值的有关信息 ************/
cout << "Min value index: "<<idx<<end1
<<"Min value address: "<<minaddr<<end1
<<"Min value: "<< (2) <<end1;
}
/******* 函数findmin的定义部分 ************
int *findmin(int *array, int size, int &index)
{
int min = 0;//max 是当前具有最小值的数组元素下标值
for(int i = 1; (3) ; i++)
{
if(array[i]< (4) )
min = i;
}
(5) ;
return array + min;//返回最小值所在内存地址
}
[填空题]阅读以下说明和Java程序,将应填入 (n) 处的字句写在对应栏内。
[说明]
下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。
[Java程序]
public class MainJava
public static void main(String[] args)
Lot_size small=new Lot_size( );
Lot_size medium=new Lot_size( );
small.set(5,5,5,25);
medium.set(10,10,10,50);
System.out.println("For a small lot of area"
+small.get_area( )+"/n");
System.out.println("the actual crops are $"
+small.get_data2( )+"/n");
System.out.println("and ideal crops are $"
+small.get data( )+"/n");
System.out.println("For a medium lot of area"
+medium.get_area( )+“/n”);
System.out.println("the actual crops are $"
+medium.get_data2( )+"/n");
System.out.println ("and ideal crops are $"
+medium.get_data( )+"/n");
class Crop_assessment
private int actual_crop;
private int ideal_crop;
public void set(int
[填空题]阅读以下说明和C++程序,将应填入 (n) 处的字句写在对应栏内。
[说明]
下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。
[C++程序]
#include <iostream.h>
class crop_assessment
int actual_crop;
int ideal_crop;
public:
void set(int in_actual,int in_ideal)
actual crop=in_actual;
ideal_crop=in_ideal;
int get_actual_crop(void) (1) ;
int get_ideal_crop(void) (2) ;)
;
Class lot_size
int length;
int width;
(3) crop;
public:
void set(int 1,int w,int a,int i)
length=1;
width=w;
crop.set(a,i);
int get_area(void)return length*width;
int get_data(void)return (4) ;
int get_data2(void)freturn (5) ;
int main( )
Los_size small,medium;
small.set(5,5,5,25);
medium.set(10,10,10,50);
cout<<"For a small lot of area"<<smallget_area( )<<“/n”;
cout<<"the actual
[简答题]
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
【说明】
下面程序的功能是计算并输出某年某月的天数,函数IsLeap Year( )能够判断是否是闰年。
【C++程序】
#
include < iostream >
using namespace std;
(1)
Month {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
};
class Date {
public:
Date(
int year, Month m_ month) {
this→year = year;
if(
(2) ) month: Jan;
else month = m_ month;
};
~Date( ){};
bool IsLeap Year( ) {
return ((year%4= =0 &&year% 100 ! =0)||
year%400= =0);
};
int
CaculateDays( ) {
switch(m_month )
{
case (3)
;{
if (4) return 29;
else return 28;
}
case Jan: case Mar: case May: case Jul: case Aug: case Oct: case Dec:
return 31;
case Apr: case Jun: case
Sop: case Nov: return 30;
}
}
private:
int year;
Month month;
};
void
main( ) {
Date day(
[简答题]【说明】
该程序运行后,输出下面的数字金字塔
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
......
1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
【程序】
#include < stdio. h >
main ( )
char max, next;
int i;
for( max = ’1’; max <= ’9’; max + +)
for(i=1;i<=20- (1) ;++i)
printf(" ");
for(next = (2) ;next <= (3) ;next ++)
printf(" %c" ,next);
for(next= (4) ;next>= (5) ;next--)
printf(" %c" ,next);
printf(" /n" );
[填空题]阅读以下说明和Java程序,将应填入 (n) 处的字句写在对应栏内。
[说明]
下面程序是为汽车市场编制的一个程序的一部分。其中automobile是基类。
[Java程序]
class MainJava{
public static void main(String agr[]){
car sedan=new car( );
sedan.initialize(24,20.0,4);
System.out.println ("The sedan can travel"
+ (1) +"miles./n");
System.out.println ("The sedan has"
+ (2) +"doors./n");
}
}
class automobile{
protected int miles_per_gallon; //汽车每加仑行驶公里数
(3) double fuel_capacity; //油箱容积
public void initialize(int in_mpg,int in_fuel){
miles_per_galion=in_mpg;
fuel_capacity=in_fuel;
}
public int get_mpg( ){//提供一辆特定汽车每加仑公里数
return miles_per_gallon;
}
public double get_fuel( ){//提供油箱容积
return fuel_capacity;
}
public double travel_distance( ){//计算满油箱情况下的可行驶总公里数
return (4) ;
}
}
class car (5) {
private int Total_doors;
public void initialize(int in_mpg,double in_fuel,int doors){
Total_doors=doors;
miles_per_gallon=in_mpg;
[填空题]阅读以下说明和C++程序,将应填入 (n) 处的字句写在对应栏内。
[说明]
下面程序是为汽车市场编制的一个程序的一部分。其中automobile是基类。
[C++程序]
//Auto.h
#ifndef AUTO_H
#define AUTO_H
class automobile
{
(1):
int miles_per_gallon; //汽车每加仑行驶公里数
float fuel_capacity; //油箱容积
public:
void initialize(int in_mpg,int in_fuel);
int get_mpg(void);
float get_fuel(void);
float travel_distance(void);
}
#endif
//Auto.cpp
#include"auto.h"
void automobile::initialize(int in_mpg,float in fuel)
{
miles_per_gallon=in_mpg;
fuel_capacity=in_fuel;
)
int automobile::get_mpg( ) //提供一辆特定汽车每加仑公里数
{return miles per_gallon;}
float automobile::get_fuel( ) //提供油箱容积
{return fuel_capacity;}
float automobile::travel_distance( )
{return (2) }
//car.h
#ifndef CAR_H
#define CAR_H
#include"auto.h"
class car: (3)
{
int Total_doors;
public:
void initialize(int
[简答题]【说明】
下面是一个Applet程序,其功能是输出已定义好的两个变量x和chr。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。
注意:不改动程序的结构,不得增行或删行。
import java. awt.*;
(1)
(2)
{
int x=10;
(3)
Label output1;
Label output2;
(4)
}
output1 = new Label("定义int类型变量"+"x,的初值为"+x);
output2 = new Label("定义char类型变量"+"chr,的初值为"+chr);
add(output1);
add(output2);
}
}
<HTML>
<HEAD>
<TITLE> ex34_3 </TITLE>
</HEAD>
<BODY>
(5)
width=400 height=400>
</applet>
</BODY>
</HTML>
[简答题]【说明】
下面是一个Applet程序,其功能是输出已定义好的两个变量x和chr。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。
注意:不改动程序的结构,不得增行或删行。
import java. awt.*;
(1)
(2)
int x=10;
(3)
Label output1;
Label output2;
(4)
output1 = new Label("定义int类型变量"+"x,的初值为"+x);
output2 = new Label("定义char类型变量"+"chr,的初值为"+chr);
add(output1);
add(output2);
<HTML>
<HEAD>
<TITLE> ex34_3 </TITLE>
</HEAD>
<BODY>
(5)
width=400 height=400>
</applet>
</BODY>
</HTML>
[简答题]【说明】 下面待修改的C程序完成的功能是:对于给定的一个长正整数,从其个位数开始,每隔一位取一个数字(即取其个位、百位、万位等数字),形成一个新的整数并输出。例如,将该程序修改正确后,运行时若输入“14251382”,则输出的整数为“4532”。 下面给出的C程序代码中有五个错误,请指出所有的错误。【C程序代码】01 #include <stdio.h>0203 int main( )04 {05 long n, num;06 int i;0708 do {09 printf("请输入一个正整数:");10 scanf("%ld", n);11 }while(n <= 0);12 k = 1;13 for (i = 1; n >= 0; i++) {14 if (i % 2 = 1) {15 num= num+ (n % 10) * k;16 k = k * 10;17 }18 n = n / 10;19 }20 printf("新数据为: %d /n",num);21 return 0;22 }
[简答题][说明]
下面的词典类Dic实现了简单的英译汉功能。程序运行后的输出为“我是一个学生”。
[C++程序]
#include <iostream.h>
#include <string.h>
#define Max 100
class Dic
{ int top;
char words[Max] [12];
char mean[Max] [20];
public:
Die( ){top=0;}
void add(char w[],char m[]){
strcpy(words[top],w);
strcpy(mean[top],m);
(1) ;
}
void trans(char str[]) {
int i=0,j=0,k=0,s;
char w[12],h[200];
while(l) {
if(str[i]! =’’&&str[i]! =’/0’)
w[j++]=str[i]; //读取单词的一个字符,记录在w中
else {
w[j]=’/0’;
for(s=0;s < top;s++)
if(strcmp(words[s],w) (2) 0) break;
if(s<top) //找到了,翻译成对应的mean[s]
{ strcpy(w,mean[s]); j= (3) ;}
else //未找到,翻译成(unknown)
{ strcpy(w,"(unknown)"}; j=9; }
for(s=0;s<j;s++)
h[k++]=w[s];
if(str[i]==’/0’) { (4) ; break;}
j=0;
}
[填空题][说明]
下面Application程序用while循环从键盘读入字符,记录输入的字符数并输出读入的字符,当输入字符“0”时结束while循环,同时结束程序。
[Java程序]
import java.io.*;
public class ContinuateInput
public (1) void main(String[] args) (2) IOException
int ch;
int counter=0;
System.out .println("请输入字符(输入0结束)");
while ((char) (ch=System.in. (3) ) != ’0’)
counter++;
System.out .println (( (4) )ch) ;
System.out .println ( ) ;
System.out.println ("counted "+counter+" total bytes. ") ;
System.out . (5) ;