第1题
程序填空题: (请阅读下面拓扑排序算法程序,完成填空,将答案写在该题横线上 ,每空3分,本题满分9分)。 int TopoSort (AdjList G) { Stack S; int indegree[MAX_VERTEX_NUM]; int i, count, k; ArcNode *p; FindID(G,indegree); /*求各顶点入度*/ InitStack(&S); for(i=0;i<g.vexnum;i++) if( ) push(&s,i); count="0;" while(!stackempty(s)) { pop(&s,&i); printf("%c",g.vertex[i].data); count++; p="G.vertexes[i].firstarc;" while( k="p-">adjvex; indegree[k]--; if(indegree[k]==0) Push(&S, k); ; } } /*while*/ if (count < G.vexnum) return(Error); else return(Ok); }
第2题
程序补丁题:请在横线上填写正确的语句。 1、下列程序的功能是把从键盘输入的整数取绝对值后输出。 #include <stdio.h> int main(void) { int x; printf("please input x:\n"); scanf("%d”, ); if(x<0) ; printf("%d\n", ); return 0; } 2、下列程序的功能是从输入的整数中,统计大于零的整数个数和小于零的整数个数。用输入0来结束输入,用i,j来放统计数,请填空完成程序。 void main() { n,i="0,j=0;" printf(“input a integer,0 for end\n”); scanf(“%d”,&n); while ( ) if(n>0) ; else j=j+1; } printf(“i=%4d,j=%4d\n”,i,j); } 3.从键盘上输入一个百分制成绩score,按下列原则输出其等级:score≥90,等级为A;80≤score<90,等级为b;70≤score<80,等级为c;60≤score<70,等级为d;score<60,等级为e。 #include> void main(){ int data; char grade; printf("Please enter the score:"); scanf("%d”, &data); switch( ) { case 10: case 9 : grade= ; break; case 8: grade=’B’; break; case 7: grade=’C’; break; case 6: grade=’D’; ; default: grade=’E’; } printf("the grade is %c”, ); }
第3题
程序填空题:完善程序,实现文件的复制功能。要求:在数字标示和注释符(//)的前面,填入合适代码;并且不要删除数字标示和注释符://(数字)。 import java.io.*; public class FileStream1{ public static void main(String args []) { try { File inFile = new File("file1.txt"); //指定源文件 /*以file2.txt文件作为构造方法的参数,在(1)所在的语句创建File类的对象*/ //(1)指定目标文件 /*以文件对象作为数据源,在(2)创建字节输入流对象fis*/ //(2); FileOutputStream fos = new FileOutputStream(outFile); int c; /*逐字节从源文件中输入;补充(3)所在语句“_____”处的代码,依次读取字节*/ while ((c = fis._____)!=-1) //(3) /*逐字节输出到fos流;补充(4)所在语句的代码,依次写字节*/ //(4); fis.close(); fos.close(); }catch (FileNotFoundException e) { System.out.println("FileStreamsTest: "+e); /*补充(5)所在语句“_____”处的代码*/ }catch(________ e){//(5) System.out.println("FileStreamsTest: "+e); } } } 提示: (1)文件类File的构造方法有多种重载形式,其构造的对象即可表示文件,也可表示文件夹;此外,构造方法只能与new运算符搭配使用。 (2)Java中所有输入数据流都拥有读数据的成员方法read(); (3)Java中所有输出数据流都拥有写读数据的成员方法write(); (4)Java中输入输出流的成员方法基本上都会抛出同一种异常。
第4题
选择适当的语句填入空白处完成程序。 以下程序的功能是:从个位开始依次取整数 x 奇数位上的数字,组成一新 数 y, 如 x=7651234 时, y=7524。 将程序补充完整。 void odd(int x, int *y){ int r, t; _______16_______; r = 1; //位权 while (x){ t = _______17_______; *y = *y + t*r; r = _______18_______; x =_______19_______; } } int main(){ int x, y; scanf("%d", &x); _______20_______; printf("%d", y); return 0; } 16. A. t=0; B. t=1; C.*y=0; D. x=0; 17. A. t+1 B.x%10 C. x/r D. x/10 18. A. r+1 B.r%10 C. r*10 D. r/10 19. A. t+1 B.x++ C. x/10 D. x/100 20. A. odd(x, &y) B. odd(x, y) C. odd(x, *y) D. odd(&x, y) 请将这5题的答案填空,中间不用有空格或任何分隔符。
第5题
程序填空题一: 下列程序的输出结果是。 A::Fun C::Do 请在答题框中给出程序中红色下划线处应填入的语句。 #include <iostream> using namespace std; class A { private: int nVal; public: void Fun() { cout << "A::Fun" << endl; } virtual void Do() { cout << "A::Do" << endl; } }; class B:public A { public: void Do() { cout << "B::Do" << endl; } }; class C:public B { public: void Do( ) { cout << "C::Do" <<endl; } void fun() { cout "c::fun" endl; }; call( ________ ) p.fun(); p.do(); int main() c c; call(c); return 0;>
第6题
程序填空题: 某软件公司B,在进行程序编写时需要用到的近似值,其中的近似值计算公式如下:前200项之积,现在需要程序员小赵编写一个函数实现求的这个近似的一个函数,请你帮助小赵将此函数补充完整。 程序如下:程序的运行结果如下所示:答题要求:可以手写拍照上传图片或者直接填写。
第7题
【填空题】观看视频,在横线上填上合适的单词。 A Tang Suit (tangzhuang) is not a suit of the Tang Dynasty (618-907) but a suit with Chinese style. Tangzhuang are tailored according to specific 1 . Brocade is the first choice when selecting 2 for tangzhuang. Stand-up collars and 3 lapels are typical styles. Exquisite 4 is another feature of tangzhuang. Even the little buttons are made with great detail. These unique buttons are the finishing touches of tangzhuang. Nowadays people put on tangzhuang for the Spring Festival or weddings. People regard tangzhuang as special clothing for important 5 . Absorbing some elements from Western designs, tangzhuang now has a more fashionable, beautiful look.
第8题
程序填空: 本题功能是创建一个线程,按照从1到5递增的顺序将这两个整数打印出来,使程序的输出结果如下: x=1,y=1 x=2,y=2 x=3,y=3 x=4,y=4 x=5,y=5 //*********Found********** public class Java_1 ___________________{ private int x=0; private int y=0; public static void main(String[] args){ Java_1 r = new Java_1(); //*********Found********** Thread t = new Thread( ___________________ ); t.start(); } public void run() { //*********Found********** int ___________________ = 0; for(;;){ x++; //*********Found********** ___________________; k++; if (k>5) ________________; //退出for循环 System.out.println("x=" + x + ",y ="+ y); } } }
第9题
【填空题】读下面程序,写出程序运行结果。 class Point{ int x; public Point(){x=0;} public Point(int x){this.x=x;} public void show(){System.out.println(x);}} class SPoint extends Point{ int y; public SPoint(){y=0;} public SPoint(int x,int y){super(x); this.y=y;} public void show(){System.out.println(x+","+y);}} public class tempDemo{ public static void main(String []args){ Point p=new Point(); p.show(); Point p1=new Point(2); p1.show(); SPoint sp=new SPoint(); sp.show(); SPoint sp1=new SPoint(2,3); sp1.show(); }} 运行结果为:
第10题
【填空题】读下面程序,写出程序运行结果。 abstract class Graph{ int a; public Graph(){a=1;} public Graph(int a){this.a=a; } public abstract void showArea(); } class Rect extends Graph{ int b; public Rect(int a,int b){super(a); this.b= b; } public void showArea(){ System.out.println("Area:"+(a*b));} } class Circle extends Graph{ public Circle(){}; public Circle(int a){super(a);} public void showArea(){ System.out.println("Area:"+(3.14*a*a)); } } public class classDemo1{ public static void main(String []args){ Graph g1; g1=new Rect(2,3); g1.showArea(); g1=new Circle(2); g1.showArea(); g1= new Circle(); g1.showArea(); } } 运行结果为:
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!