收藏 分销(赏)

电大秋C语言复习题.doc

上传人:a199****6536 文档编号:3529991 上传时间:2024-07-08 格式:DOC 页数:15 大小:41KB
下载 相关 举报
电大秋C语言复习题.doc_第1页
第1页 / 共15页
电大秋C语言复习题.doc_第2页
第2页 / 共15页
电大秋C语言复习题.doc_第3页
第3页 / 共15页
电大秋C语言复习题.doc_第4页
第4页 / 共15页
电大秋C语言复习题.doc_第5页
第5页 / 共15页
点击查看更多>>
资源描述

1、资料内容仅供您学习参考,如有不当或者侵权,请联系改正或者删除。复习题一、 填空题( 每空2分) 1、 为使c#源程序能够编译和执行, 必须安装 。2、 c#中的三元运算符是 。3、 类成员的可访问形式为_、 _、 _。4、 当整数a赋值给一个object对象时, 整数a将会被 。5、 float f=263.981F; int i=(int)f; i的值是 。6、 面向对象的语言具有_性、 _性和_性。7、 ADO.NET中的五个主要对象_、 _、 _、 _、 _。二、 写出下列程序运行结果( 每题6分) 1、 using System;class jieguo1public static v

2、oid Main() bool x; int y=10,z=3; uint i=8,j=65535; x=(y2; Console.WriteLine(”i=0”,i);2、 using System;class jieguo2 public static void Main()int a,x,y;string z;Console.WriteLine(”请输入一个整数: ”);z= Console.ReadLine();x=Int32.Parse(z);if(x0) a=-1; else a=x/10;switch(a) case -1:y=0;break; case 0:y=x;break;

3、 case 1:y=10;break; case 2:case 3:y=(int)(-0.5*x+30);break;default:y=-2; break;if (y!=-2) Console.WriteLine(”y=0”,y);else Console.WriteLine(”error!”);x=10; y是: x=-10;y是: x=40; y是: 3、 using System;class jieguo3 public static void Main()string aa=”这是第一t行,n这是第二行.n这是第”三”行”; string bb=”这是第一t行,n这是第二行.n这是第

4、”三”行”;Console.WriteLine(”aa为: ”);Console.WriteLine(aa);Console.WriteLine(”bb为: ”);Console.WriteLine(bb);4、 using System;public class jieguo4 public static void Main() int myArray = new int2;myArray0 = new int5 1,3,5,7,9;myArray1 = new int4 0, 2, 4, 6;for (int i=0; i myArray.Length; i+) Console.Write

5、(第(0)个数组: , i);for (int j=0; j myArrayi.Length; j+)Console.Write(0 , myArrayij);Console.WriteLine();5、 using System;class jieguo5 public static void Main() int varA = 10; int varB = 20; int andResult = varA & varB; Console.WriteLine(10 & 20 = 0, andResult); int orResult = varA | varB; Console.WriteL

6、ine(10 | 20 = 0, orResult); int notorResult = varA varB; Console.WriteLine(10 20 = 0, notorResult); Console.WriteLine( 0:x8 = 1:x8, varA, varA); 6、 using System;class jieguo6public static void Main()int i=1,sum=0; while(i=100) sum +=i; i+;Console.WriteLine(”sum=”,sum);7、 using System;class jieguo7pu

7、blic static void Main()int i,j,k,m;int queArray = new int5,2,8,12,36,24,88,1,103,69;for(j=0;jqueArray.Length;j+)k=j;for(i=j+1;i10;i+)if(queArrayiqueArrayk) k=i;if(k!=j)m=queArrayj;queArrayj = queArrayk;queArrayk = m;for(j=0;j10;j+)Console.Write(0 , queArrayj);8、 using System;public class jieguo8 sta

8、tic void Add(int i) i+; static void AddWithRef(ref int i) i+; public static void Main() int i1 = 10; int i2 = 20; Add(i1); AddWithRef(ref i2); Console.WriteLine(”i1=”+i1); Console.WriteLine(”i2=”+i2); 9、 三、 指出程序或函数的功能( 每题6分) 1、 using System;class gongneng1 public static void Main()for(int i=0;i15;i+

9、)if(i=12) continue;Console.WriteLine(”i=0”,i);2、 using System;class gongneng2 public static void Main() for(int i = 1; i = 9; i+) for(int j = 1; j = i; j+) Console.Write(0x1=2t, i, j, i*j); Console.WriteLine(); 3、 using System;class gongneng3public static void Main(String args)string strName; strNam

10、e = args0; Console.WriteLine(This is the first argument: 0!, strName); 4、 using System;class gongneng4public static int Main(string args) if(args.Length = A)if(chLetter = a & chLetter = z)Console.WriteLine(0 是个小写字母, chLetter);return 0;if(Char.IsDigit(chLetter)Console.WriteLine(0 是个数字, chLetter);retu

11、rn 0;Console.WriteLine(0 是个特殊字符, chLetter);return 1;5、 using System;class gongneng5public static void Main() float a= new float 82,90,78,63,75,94,87,86,99,71;int i;float s=0,aver,max=0,min=100;for(i=0;imax) max=ai;if(ai=1)for(int i=2;i=n;i+)s *= i;Console.WriteLine(n!=0, s);7、 using System;class gon

12、gneng7 public static void Main() char ch = (char) Console.Read(); switch(ch.ToLower() case a : case e : case i : case o : case u : Console.WriteLine(字母0是元音字母, ch);break; default :Console.WriteLine(字母0是辅音字母, ch);break; 四、 编程题( 每题10分) 1、 请学生经过键盘输入行数和列数, 然后打出一个由星号组成的方阵。( 10分) 例如: 输入行号 3 输入列号 3 结果为: * * * * * * * * *2、 一列数的规则如下: 1、 1、 2、 3、 5、 8、 13、 21、 34. 求第30位数是多少, 用递归算法实现。( 10分) 3、 由程序随机产生10个数, 并把这10个数按从小到大的顺序输出。4、 输出如下所示的九九乘法表。1*1=12*1=22*2=43*1=3 3*2=63*3=99*1=99*2=189*3=279*4=369*5=459*6=549*7=639*8=729*9=81

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 教育专区 > 远程教育/电大

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服