/*Convert.ToInt("213165");

int a=12345;
string sn=a.ToString();//把a转换成字符串sn
int b=int.Parse(sn);//把sn转换成整数b,结果b=a*/

using System;
class Program
{
    static void Main()
    {
        short i = 289;
        byte b;
        b = (byte)i;//产生截断,即减去256,得到33,而 ! 的ASCII码就是33
        char c = (char)b;
        Console.WriteLine("{0}", c);
    }
}

//14,用foreach语句输出字符串型数组
using System;
class Program
{
    static void Main()
    {
        string[] WeekDays = new string[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
        Console.WriteLine("该数组的长度为:{0}", WeekDays.Length);
        Console.WriteLine("以下为数组内容:");
        int i = 1;
        foreach (string day in WeekDays)
            Console.WriteLine("该值为数组的第{0}个值--{1}", i++, day);
    }
}

//15,完成任务
using System;
class Program
{
    static void Main()
    {
        int i;
        int[] f = new int[20];
        f[0] = 1;
        f[1] = 1;
        for (i = 2; i < f.Length; i++)
            f[i] = f[i - 2] + f[i - 1];
        for(i=0;i<f.Length;i++)
        {
            if (i % 5 == 0 && i > 0)
                Console.WriteLine();
            Console.Write("{0,8}", f[i]);
        }
        Console.WriteLine();
    }
}
//16,有10位学生的成绩分别是,,,,试编写程序输出10个学生的成绩,找出其中的最高分极其在这批数中德位置
using System;
class Program
{
    static void Main()
    {
        int[] scores = new int[11] { 0, 67, 34, 90, 88, 55, 74, 95, 82, 43, 90 };
        int i, max, max_in;
        max = scores[1];
        max_in = 1;
        for(i=2;i<scores.Length;i++)
        {
            if (scores[i] > max)
            {
                max = scores[i];
                max_in = i;
            }
            Console.WriteLine("输出10个学生的成绩:");
            for (i = 1; i < scores.Length; i++)
            {
                Console.Write("{0}  ", scores[i]);
            }
            Console.WriteLine();
            Console.WriteLine("最高分:{0}", max);
            Console.WriteLine("第一个最高分的位置:{0}", max_in);
        }
    }
}
//17,用冒泡法和选择法分别将由键盘输入的十个整数拍成升序
using System;
class Program
{
    static void Main()
    {
        int[] a = new int[] { 9, 8, 5, 6, 2, 0 };
        int i, j, t;
        for(i=0;i<6-1;i++)
            for(j=0;j<6-1-i;j++)
                if(a[j]>a[j+1])
                {
                    t = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = t;
                }
        Console.WriteLine("排序的结果是:");
        for (i = 0; i < 6; i++)
            Console.Write("{0}  ", a[i]);
        Console.WriteLine();
    }
}
//18,冒泡排序,手动输入
using System;
class Program
{
    static void Main()
    {
        int[]a=new int[10];
        int i,j,t;
        Console.WriteLine("请输入十个整数:");
        for (i = 0; i < 10; i++)
        {
            a[i] = Convert.ToInt32(Console.ReadLine());
        }
        Console.WriteLine();
        for(i=0;i<10-1;i++)
            for (j = 0; j < 10 - 1 - i; j++)
                if(a[j]>a[j+1])
            {
                t = a[j];
                a[j] = a[j + 1];
                a[j + 1] = t;
            }
        for (i = 0; i < 10; i++)
        {
            Console.Write("{0}  ", a[i]);
            Console.WriteLine();
        }
    }
}
//19,选择法 将六个已知整数排成升序
using System;
class Program
{
    static void Main()
    {
        int[ ] a = new int[ ] { 9, 8, 5, 6, 2, 0 };
        int i, j, t;
        for (i = 0; i < 6 - 1; i++)
            for (j = i + 1; j < 6; j++)
                if (a[i] > a[j])
                {
                    t = a[i];
                    a[i] = a[j];
                    a[j] = t;
                }
        Console.WriteLine("排序的结果为:");
        for(i=0; i<6; i++)
            Console.Write("{0}  ",a[i]);
        Console.WriteLine();
    }
}

//20,用选择法 对 十个键盘输入的数 排升序
using System;
class Program
{
    static void Main()
    {
        int[] a = new int[10];
        int i, j, t;
        Console.WriteLine("请输入十个整数");
        for (i = 0; i < 10; i++)
        {
            a[i] = Convert.ToInt32(Console.ReadLine());
        }
        Console.WriteLine();
        for(i=0;i<10-1;i++)
            for (j = i + 1; j < 10; j++)
                if (a[i] > a[j])
                {
                    t = a[i];
                    a[i] = a[j];
                    a[j] = t;
                }
        for (i = 0; i < 10; i++)
        {
            Console.Write("{0}  ", a[i]);
        }
        Console.WriteLine();
    }
}
//21,二维数组的声明
using System;
class Program
{
    static void Main()
    {
        int [ , ]score=new int[3,5];
        score = new int[,] { { 97, 87, 92, 78, 83 }, { 97, 87, 92, 78, 83 }, { 70, 65, 80, 91, 76 } };
        Console.Write("课程1\t课程2\t课程3\t课程4\t课程5");
        string str = " \n";
        for(int i=0;i<score.GetLength(0);i++)
        {
            for (int j = 0; j < score.GetLength(1); j++)
            {
                str += " ";
                str += score[i, j].ToString() + "\t";//制表
            }
            str += "\n";//换行
        }
        Console.WriteLine(str);
    }
}
//22,用二维数组实现矩阵转置
using System;
class Program
{
    static void Main()
    {
        int i, j, d;
        int[,] data = new int[5,5];
        for (i = 0; i < 5; i++)
            for (j = 0; j < 5; j++)
                data[i, j] = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("转置前的矩阵:");
        for (i = 0; i < 5; i++)
        {
            for (j = 0; j < 5; j++)
                Console.Write("{0,4 }", data[i, j]);
            Console.WriteLine();
        }
        for(i=0;i<5-1;i++)
            for (j = i + 1; j < 5; j++)//实现矩阵的转置
            {
                d = data[i, j];
                data[i, j] = data[j, i];
                data[j, i] = d;
            }
        Console.WriteLine("\n转置后的矩阵:");
        for (i = 0; i < 5; i++)
        {
            for (j = 0; j < 5; j++)
                Console.Write("{0,4}", data[i, j]);
            Console.WriteLine();
        }
    }
}

//23,字符数组的输出
using System;
class Program{
    static void Main(){
        char[] c = new char[10] { 'I', ' ', 'a', 'm', ' ','a',' ', 'b', 'o', 'y' };
        int i;
        for (i = 0; i < 10; i++)
        {
            Console.Write("{0}", c[i]);
        }
        Console.WriteLine();
    }
}
//24.二维字符数组输出
using System;
class Program
{
    static void Main()//二维字符数组
    {
        char[ , ] d = new char[5, 5] { { ' ', ' ', '*', ' ', ' ' }, { ' ', '*', ' ', '*', ' ' }, { '*', ' ', ' ', ' ', '*' }, { ' ', '*', ' ', '*', ' ' }, { ' ', ' ', '*', ' ', ' ' } };
        int i, j;
        for (i = 0; i < 5; i++)
        {
            for (j = 0; j < 5; j++)
                Console.Write("{0}", d[i, j]);
            Console.WriteLine();
        }
    }
}
//25,创建一个控制台应用程序,使用string类声明一个字符串变量并进行初始化,然后获取该字符串中的某个字符
using System;
class Program
{
    static void Main()
    {
        string str = "我钟爱C#!";
        char ch1 = str[1];
        char ch2 = str[2];
        Console.WriteLine("字符串:{0}中德第2个字符是:{1}",str,ch1);
        Console.WriteLine("字符串:{0}中的第3个字符是:{1}",str,ch2);
    }
}
//26,创建一个控制台应用程序,声明两个string类型的变量str1和str2,然后使用Format方式格式化这两个string变量,最后输出格式化后的字符串
using System;
class Program
{
    static void Main()
    {
        string str1= "努力学习C#!";
        string str2 = "饱尝编程的愉悦";
        string newstr = String.Format("{0},{1}!!!", str1, str2);
        Console.WriteLine(newstr);
    }
}

<C#任务导引教程>练习三的更多相关文章

  1. 2DToolkit官方文档中文版打地鼠教程(三):Sprite Collections 精灵集合

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  2. Laravel大型项目系列教程(三)之发表文章

    Laravel大型项目系列教程(三)之发表文章 一.前言 上一节教程中完成了用户管理,这节教程将大概完成发表Markdown格式文章并展示的功能. 二.Let's go 1.数据库迁移 文章模块中我们 ...

  3. Python导出Excel为Lua/Json/Xml实例教程(三):终极需求

    相关链接: Python导出Excel为Lua/Json/Xml实例教程(一):初识Python Python导出Excel为Lua/Json/Xml实例教程(二):xlrd初体验 Python导出E ...

  4. [译]MVC网站教程(三):动态布局和站点管理

    目录 1.   介绍 2.   软件环境 3.   在运行示例代码之前(源代码 + 示例登陆帐号) 4.   自定义操作结果和控制器扩展 1)   OpenFileResult 2)   ImageR ...

  5. WCF入门教程(三)定义服务协定--属性标签

    WCF入门教程(三)定义服务协定--属性标签 属性标签,成为定义协议的主要方式.先将最简单的标签进行简单介绍,以了解他们的功能以及使用规则. 服务协定标识,标识哪些接口是服务协定,哪些操作时服务协定的 ...

  6. Senparc.Weixin.MP SDK 微信公众平台开发教程(三):微信公众平台开发验证

    要对接微信公众平台的"开发模式",即对接到自己的网站程序,必须在注册成功之后(见Senparc.Weixin.MP SDK 微信公众平台开发教程(一):微信公众平台注册),等待官方 ...

  7. Docker入门教程(三)Dockerfile

    Docker入门教程(三)Dockerfile [编者的话]DockerOne组织翻译了Flux7的Docker入门教程,本文是系列入门教程的第三篇,介绍了Dockerfile的语法,DockerOn ...

  8. HMM 自学教程(三)隐藏模式

    本系列文章摘自 52nlp(我爱自然语言处理: http://www.52nlp.cn/),原文链接在 HMM 学习最佳范例,这是针对 国外网站上一个 HMM 教程 的翻译,作者功底很深,翻译得很精彩 ...

  9. WebRTC VideoEngine超详细教程(三)——集成X264编码和ffmpeg解码

    转自:http://blog.csdn.net/nonmarking/article/details/47958395 本系列目前共三篇文章,后续还会更新 WebRTC VideoEngine超详细教 ...

随机推荐

  1. JVM学习笔记——堆

    堆 Heap 一个 JVM 只有一个堆,堆也是 Java 内存管理的核心区域.在 JVM 启动时堆被创建,同时大小在启动时已设定好,堆是 JVM 管理最大的一块内存空间,其大小可以调节. 堆的内存空间 ...

  2. 通过Swagger文档生成前端service文件,提升前端开发效率

    在企业级的项目开发过程中,一般会采用前后端分离的开发方式,前后端通过api接口进行通信,所以接口文档就显得十分的重要. 目前大多数的公司都会引入Swagger来自动生成文档,大大提高了前后端分离开发的 ...

  3. SpringBoot配置文件application

    配置文件 SpringBoot使用一个全局的配置文件 , 配置文件名称是固定的,有两种文件格式: application.properties 语法结构 :key=value application. ...

  4. 2020.1.30--vj补题

    C - C CodeForces - 991C 题目内容: After passing a test, Vasya got himself a box of n candies. He decided ...

  5. GIS应用|快速开发REST数据服务

    随着计算机的快速发展,GIS已经在各大领域得到应用,和我们的生活息息相关, 但是基于GIS几大厂商搭建服务,都会有一定的门槛,尤其是需要server,成本高,难度大,这里介绍一种在线GIS云平台,帮你 ...

  6. 分布式事物SAGA

    目录 概述SAGA SAGA的执行方式 存在的问题 重试机制 SAGA VS TCC 实现SAGA的框架 概述SAGA SAGA是1987 Hector & Kenneth 发表的论文,主要是 ...

  7. LeetCode:回溯算法

    回溯算法 这部分主要是学习了 labuladong 公众号中对于回溯算法的讲解 刷了些 leetcode 题,在此做一些记录,不然没几天就忘光光了 总结 概述 回溯是 DFS 中的一种技巧.回溯法采用 ...

  8. 联赛膜你测试20 T1 Simple 题解 && NOIP2017 小凯的疑惑 题解(赛瓦维斯特定理)

    前言: 数学题,对于我这种菜B还是需要多磨啊 Simple 首先它问不是好数的数量,可以转化为用总数量减去是好数的数量. 求"好数"的数量: 由裴蜀定理得,如果某个数\(i\)不能 ...

  9. 海思 core 电压动态调整

    http://www.eda365.com/forum.php?mod=viewthread&tid=108620&_dsign=5bee4dcb http://www.eda365. ...

  10. C语言单片机项目实战超声波雷达测距

    本实验是基于MSP430利用HC-SR04超声波传感器进行测距,测距范围是3-65cm,讲得到的数据显示在LCD 1602液晶屏上. 模块工作原理如下 (1)采用 IO 触发测距,给至少 10us 的 ...