第一范文网 - 专业文章范例文档资料分享平台

面向对象程序设计实验报告

来源:用户分享 时间:2025/8/2 22:24:33 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

} }

(5) 分析程序,写出程序的运行结果,并上机进行验证。

using System; namespace _1 {

class Program {

enum WeekDay { sun,mon,tue,wed,thu,fri,sat} static void Main() {

WeekDay a = WeekDay.sun; Console.WriteLine(a); WeekDay b = (WeekDay)4; Console.WriteLine(b); Console.Read(); } }

}

(6) 分析程序,写出程序的运行结果,并上机进行验证。

using System; namespace _1 {

class Program {

static void Main(string[] args) {

int[][] jagArray=new int[2][]{new int[5],new int[3]}; for (int i = 0; i < jagArray.GetLength(0); i++) {

for (int j = 0; j < jagArray[i].Length; j++) jagArray[i][j] = i + j; }

for (int k = 0; k < 2;k++) {

Console.WriteLine(\ for(int m=0;m

Console.Read(); } } }

(7) 分析程序,写出程序的运行结果,并上机进行验证。

using System; namespace _1 {

class Program {

static void Main(string[] args) {

object x; x = 1;

Console.WriteLine(\ x = 10.01;

Console.WriteLine(\ x = '\a';

Console.WriteLine(\ x = \

Console.WriteLine(\ Console.Read(); } } }

(8) 分析程序,写出程序的运行结果,并上机进行验证。

using System; namespace _1 {

class Program {

static void Main(string[] args) {

Console.Write(\请输入1-12之间的任意一个整数:\ string s=Console.ReadLine(); int month =int .Parse(s); switch(month) {

case 1:Console.WriteLine(\ case 2:Console.WriteLine(\ case 3:Console.WriteLine(\ case 4:Console.WriteLine(\ case 5:Console.WriteLine(\ case 6:Console.WriteLine(\ case 7:Console.WriteLine(\ case 8:Console.WriteLine(\ case 9:Console.WriteLine(\ case 10:Console.WriteLine(\

case 11:Console.WriteLine(\ case 12:Console.WriteLine(\

default:Console.WriteLine(\输入错误,转换失败。\ }

Console.Read(); } } }

(9)分析程序,写出程序的运行结果,并上机进行验证。

using System; namespace _1 {

class Program {

static void Main(string[] args) {

int[,] a = new int[5, 5]; a[0, 0] = 1;

for (int i = 1; i < 5; i++) {

a[i, 0] = 1; a[i, i] = 1;

for (int j = 1; j < i; j++)

a[i, j] = a[i - 1, j - 1] + a[i - 1, j]; }

for (int i = 0; i < 5; i++) {

for (int j = 0; j <= i;j++ )

Console.WriteLine(\ Console.WriteLine(); }

Console.Read(); } } }

(10)分析程序,写出程序的运行结果,并上机进行验证。

using System; namespace _1 {

class Program {

static void Main(string[] args) {

int odd = 0, even = 0;

int[] array = new int[] { 0, 4, 7, 8, 9, 10, 14, 17, 19, 24, 56 }; foreach (int i in array) {

if (i % 2 == 0) even++; else odd++; }

Console.WriteLine(\个奇数,{1}个偶数\ } } }

(11)分析程序,写出程序的运行结果,并上机进行验证。

using System;

public class TestDoWhile {

public static void Main () {

int x; int y = 0; do {

x = y++;

Console.WriteLine(x); }

while(y < 5); } }

(12)分析程序,写出程序的运行结果,并上机进行验证。

using System; namespace _1 {

class Program {

static void Main(string[] args) {

Console.WriteLine(\ for (int i = 0; i < 10; i++) {

if (i == 5) break;

Console.WriteLine(\ }

Console.WriteLine(\ for (int i = 0; i < 10; i++)

搜索更多关于: 面向对象程序设计实验报告 的文档
面向对象程序设计实验报告.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c9ougf35blu8ojis8frbl_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top