C#基础第三天-作业答案-集合-冒泡排序-模拟名片
.冒泡排序
Console.WriteLine("对集合里的数进行排序,请输入第一个数:");
int a = int.Parse(Console.ReadLine());
Console.WriteLine("对集合里的数进行排序,请输入第二个数:");
int b = int.Parse(Console.ReadLine());
Console.WriteLine("对集合里的数进行排序,请输入第三个数:");
int c = int.Parse(Console.ReadLine());
Console.WriteLine("对集合里的数进行排序,请输入第四个数:");
int d = int.Parse(Console.ReadLine());
Console.WriteLine("对集合里的数进行排序,请输入第五个数:");
int e = int.Parse(Console.ReadLine());
int mid = ;
List<int> iList = new List<int>();
iList.Add(a);
iList.Add(b);
iList.Add(c);
iList.Add(d);
iList.Add(e);
for (int i = ; i<iList.Count; i++) {
for (int j = i + ; j < iList.Count; j++) {
if (iList[i] < iList[j]) {
mid = iList[i];
iList[i]=iList[j];
iList[j] = mid;
}
}
}
Console.WriteLine("排序后的结果为:");
foreach (int i1 in iList) {
Console.Write(i1+" ");
}
. 名片两种集合:
List集合:
List<Object> list = new List<Object>();
list.Add("身份证号码");
list.Add("电话号码");
list.Add("性别");
list.Add("姓名");
list.Add("身高");
list.Add("年龄");
list.Add("体重");
List<Object> list1 = new List<Object>();
list1.Add("");
list1.Add("");
list1.Add("男");
list1.Add("刘夕饶");
list1.Add("172cm");
list1.Add("27岁");
list1.Add("75kg");
while (true) {
Console.Write("请输入你要查询的名字:");
string name = Console.ReadLine();
if (list1.Contains(name))
{
foreach (Object obj in list)
{
Console.Write(" " + obj + " ");
}
Console.WriteLine();
foreach (Object obj1 in list1)
{
Console.Write(obj1 + " ");
}
Console.WriteLine();
}
else
{
Console.WriteLine("查无此人");
}
ArrayList集合:
///另一种方法
ArrayList Card = new ArrayList();
Card.Add(new ArrayList() { "", "", "男", "小胖", "178cm", "", "200kg" });
Card.Add(new ArrayList() { "", "", "男", "石瑀", "178cm", "", "200kg" });
Card.Add(new ArrayList() { "", "", "男", "张三", "178cm", "", "200kg" });
Card.Add(new ArrayList() { "", "", "男", "李四", "178cm", "", "200kg" });
Card.Add(new ArrayList() { "", "", "男", "李五", "178cm", "", "200kg" });
Card.Add(new ArrayList() { "", "", "男", "李六", "178cm", "", "200kg" });
string name = string.Empty;
Console.WriteLine("请输入您要查找的人名");
name = Console.ReadLine();
for (int i = ; i < Card.Count; i++)
{
ArrayList card = (ArrayList)Card[i];
if(card.Contains(name) == true)
{
Console.WriteLine(@"身份证号:{0},电话号码:{1},性别:{2},姓名:{3},身高:{4},年龄:{5},体重:{6}",
card[], card[], card[], card[], card[], card[], card[]);
Console.ReadLine();
}
else
{
continue;
}
if (i == Card.Count - )
{
Console.WriteLine("对不起,没有您要找的人!");
Console.WriteLine(" ");
Console.ReadKey();
}
}
本系列教程:
C#基础总结之八面向对象知识点总结-继承与多态-接口-http://www.cnblogs.com/spring_wang/p/6113531.html
C#基础总结之七面向对象知识点总结1http://www.cnblogs.com/spring_wang/p/6113526.html
C#基础总结之六 DataTable (临时表/数据源) 和Datatable 名片练习http://www.cnblogs.com/spring_wang/p/6113520.html
C#基础总结之五Dictionary<string, string[]>和while循环http://www.cnblogs.com/spring_wang/p/6113514.html
C#基础总结之四List-Hashtable-冒泡排序http://www.cnblogs.com/spring_wang/p/6113504.html
C#基础总结之三循环控制-for-数组-乘法表-arraylisthttp://www.cnblogs.com/spring_wang/p/6113496.html
C#基础总结之二循环控制-运算符http://www.cnblogs.com/spring_wang/p/6113484.html
C#基础总结之一变量常量-if嵌套语句-witch结构-类型转换http://www.cnblogs.com/spring_wang/p/6113476.html
C#基础课程之六(临时表)DataTable使用方法http://www.cnblogs.com/spring_wang/p/6113454.html
C#基础课程之五集合(HashTable,Dictionary)http://www.cnblogs.com/spring_wang/p/6113404.html
C#基础课程之四集合(ArrayList、List<泛型>)http://www.cnblogs.com/spring_wang/p/6113396.html
C#基础课程之三循环语句http://www.cnblogs.com/spring_wang/p/6113383.html
C#基础课程之二变量常量及流程控制http://www.cnblogs.com/spring_wang/p/6113372.html
C#基础课程之一注释和控制台、一些常识http://www.cnblogs.com/spring_wang/p/6113361.html
C#基础第九天-作业答案-储蓄账户(SavingAccount)和信用账户(CreditAccount) http://www.cnblogs.com/spring_wang/p/6113291.html
C#基础第九天-作业-储蓄账户(SavingAccount)和信用账户(CreditAccount) http://www.cnblogs.com/spring_wang/p/6113285.html
C#基础第八天-作业答案-设计类-面向对象方式实现两个帐户之间转账http://www.cnblogs.com/spring_wang/p/6113274.html
C#基础第八天-作业-设计类-面向对象方式实现两个帐户之间转账http://www.cnblogs.com/spring_wang/p/6113258.html
C#基础第七天-作业答案-利用面向对象的思想去实现名片-动态添加http://www.cnblogs.com/spring_wang/p/6113232.html
C#基础第七天-作业-利用面向对象的思想去实现名片-动态添加http://www.cnblogs.com/spring_wang/p/6113224.html
C#基础第六天-作业-利用面向对象的思想去实现名片http://www.cnblogs.com/spring_wang/p/6113028.html
C#基础第六天-作业答案-利用面向对象的思想去实现名片http://www.cnblogs.com/spring_wang/p/6113033.html
C#基础第五天-作业答案-用DataTable制作名片集http://www.cnblogs.com/spring_wang/p/6113022.html
C#基础第五天-作业-用DataTable制作名片集http://www.cnblogs.com/spring_wang/p/6113013.html
C#基础第四天-作业答案-Hashtable-list<KeyValuePair>泛型实现名片http://www.cnblogs.com/spring_wang/p/6113005.html
C#基础第四天-作业-Hashtable-list<KeyValuePair>泛型实现名片http://www.cnblogs.com/spring_wang/p/6113000.html
C#基础第三天-作业答案-集合-冒泡排序-模拟名片http://www.cnblogs.com/spring_wang/p/6112888.html
C#基础第三天-作业-集合-冒泡排序-模拟名片http://www.cnblogs.com/spring_wang/p/6112885.html
C#基础第二天-作业答案-九九乘法表-打印星星http://www.cnblogs.com/spring_wang/p/6112881.html
C#基础第二天-作业-九九乘法表-打印星星http://www.cnblogs.com/spring_wang/p/6112875.html
C#基础第一天-作业答案http://www.cnblogs.com/spring_wang/p/6112872.html
C#基础第一天-作业http://www.cnblogs.com/spring_wang/p/6112867.html
C#-string.Format对C#字符串格式化http://www.cnblogs.com/spring_wang/p/6077098.html
C#基础第三天-作业答案-集合-冒泡排序-模拟名片的更多相关文章
- C#基础第三天-作业-集合-冒泡排序-模拟名片
1.名片:用两种集合(ArrayList/List<>)去输出余下信息.身份证号码,电话号码,性别,姓名,身高,年龄,体重.需求:根据 姓名 去查询某一行数据.如果集合中不存在提示(“自定 ...
- C#基础第七天-作业答案-利用面向对象的思想去实现名片-动态添加
class Card { private string name; public string Name { get { return name; } set { name = value; } } ...
- C#基础第五天-作业答案-用DataTable制作名片集
.DataTable 实现 DataTable PersonCard = new DataTable(); //创建一个DataTable DataTable PersonCardCopy = new ...
- C#基础第四天-作业答案-Hashtable-list<KeyValuePair>泛型实现名片
.Hashtable 实现 Hashtable table = new Hashtable(); while (true) { Console.WriteLine("------------ ...
- C#基础第四天-作业-Hashtable-list<KeyValuePair>泛型实现名片
1.名片集: 名片集实现功能:不限定集合实现 增加,查询,查询全部,删除 功能,需求条件: 根据姓名去(查询/删除)某一行数据.指定:姓名,年龄,性别,爱好,联系方式. 采用技术:Hashtable- ...
- 前端-JavaScript2-1——JavaScript基础复习及上次作业答案
昨天讲解的JS是编程最最简单的一些基础知识,复习一下: JavaScript书写环境,<script>标签 1 <script type=”text/javascript”&g ...
- C语言基础第三次作业
题目7-1,寻找最小值 1.实验代码: #include<stdio.h> int main() { int i,mark,min,n; scanf("%d", &am ...
- C#基础第九天-作业答案-储蓄账户(SavingAccount)和信用账户(CreditAccount)
class Bank { //Dictionary<long,Account> dictionary=new Dictionary<long,Account>(); DataT ...
- C#基础第八天-作业答案-设计类-面向对象方式实现两个帐户之间转账
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
随机推荐
- unity3d与web网页通信
总结一下: Unity3D 中的 C# 和 JavaScript 脚本之间是可以互相访问并交互的,但是要求这些被访问和操作的 C# 和 JavaScript 组件必须放在名为 Standard Ass ...
- Laravel返回不重复的某个字段信息列表
->groupBy('brand_id') ->pluck('brand_id');
- nano在CentOS上的安装和使用
安装: yum -y install nano 打开新建:nano 路径+文件名 查看用:cat path/filename如果改文件存在,上面的命令将打开这个文件:如果文件不存在则将会创建一个新文件 ...
- Cocos2d-js 3.0 颜色变换(调整sprite/图片的色调)
Flash在滤镜方面做得比较成熟,starling也有很多现成的办法. 但Cocos2D这里就显得比较单薄,百度/谷歌很少相关资料. 后续如果有时间,再慢慢整理各种滤镜效果. 这里先介绍一下颜 ...
- cocos2d-js 3.0 rc2 自定义UI控件组件 例子:能播放动画的MenuItem。MenuItemSprite的bug
其实总体自定义UI组件都比较简单,尤其是cocos2d-js是开源的,如果有什么不明白的直接看js代码或者C++代码即可.当然js代码基本就够了. 另外,js的ctor函数虽然说是构造函数,但毕竟不是 ...
- python 模块之platform模块(基本了解)
# -*- coding: cp936 -*-#python 27#xiaodeng#python 模块之platform模块(基本了解)#获取底层平台的识别数据 #知道该模块用途即可,需要使用时直接 ...
- uml中活动图与流程图的区别
活动图定义: 活动图是UML用于对系统的动态行为建模的另一种常用工具,它描述活动的顺序,展现从一个活动到另一个活动的控制流.活动图在本质上是一种流程图. 它是UML中用于对系统动态活动建模的图形,反映 ...
- 转:ogre的编译及安装
ogre在Windows环境下的编译及安装过程: 1.从下面网址下载OGRE 1.8.1 Source For Windows.Dependencies source repository with ...
- macbook上安装homestead
参考资料: 1:https://solarhell.com/post/2016/04/homestead 2:https://phphub.org/topics/491 3:http://larave ...
- 【centos6】给php命令设置全局变量三种方式
方法一:直接运行命令export PATH=$PATH:/usr/local/webserver/php/bin 和 export PATH=$PATH:/usr/local/webserver/my ...