黑马程序员_C#学习之数组(代码)
来源:互联网 发布:adobe系列软件下载 编辑:程序博客网 时间:2024/04/29 19:59
---------------------- Windows Phone 7手机开发、.Net培训、期待与您交流! ----------------------
using System;using System.Collections.Generic;using System.Text;namespace Ex7_6{ class Program { static void Main(string[] args) { //C#二位数组转置输出 int[,] OriginalArray = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 }, { 13, 14, 15 } }; int[,] ReversionArray=new int[3,5]; for (int i = 0; i <= OriginalArray.GetUpperBound(0); i++) { for (int j = 0; j <= OriginalArray.GetUpperBound(1); j++) { ReversionArray[j, i] = OriginalArray[i, j]; } } Console.WriteLine("原始的数组为:"); PrintArray(OriginalArray); Console.WriteLine("转置后的数组为:"); PrintArray(ReversionArray); Console.ReadLine(); } public static void PrintArray(int[,] intArray) { for (int i = 0; i <= intArray.GetUpperBound(0); i++) { for (int j = 0; j <=intArray.GetUpperBound(1); j++) { Console.Write(intArray[i, j] + " "); } Console.WriteLine(); } } }}
using System;using System.Collections.Generic;using System.Text;namespace text_{ class Program { public static int a; public static void OneString(string s) { //C#输入一串字符串求单词个数 string[] thisString = s.Split(new char[] { ' ' }); a = thisString.Length; //测试有无多个连续空格代码 // for (int i=0; i < thisString.Length; i++) // { // Console.WriteLine("qq*"+thisString[i]+"*qq"); // } for (int i = 0; i < thisString.Length; i++) { if (thisString[i] == "") a--; } Console.WriteLine("此字符串中{0}个单词!", a); } static void Main(string[] args) { //string onestring = " a b c d e f g h "; Console.WriteLine("输入一个包含单词的字符串:"); string onestring = Console.ReadLine(); Console.WriteLine(onestring); OneString(onestring); Console.Read(); } }}
int[] a = new int[12]; Random ran = new Random(); for (int i = 0; i < a.Length; i++) { one: a[i] =(int)ran.Next()+1; for(int j=0;j<i;j++) { if(a[i]==a[j]) goto one; } } foreach (int n in a) Console.Write(n + " "); int temp; int m = 0; for (int j = 0; j<a.Length; j++) { temp = j; for(int i=j+1;i<a.Length;i++ ) { if (a[i] < a[temp]) temp = i; } if(temp!=j) m = a[j]; a[j] = a[temp]; a[temp] = m; } Console.WriteLine(); Console.WriteLine("输出排序后的结果:"); foreach (int n in a) Console.Write(n + " ");
---------------------- Windows Phone 7手机开发、.Net培训、期待与您交流! ----------------------
详细请查看:http://net.itheima.com/
- 黑马程序员_C#学习之数组(代码)
- 黑马程序员_c#基础知识学习笔记:数组
- 黑马程序员_C#数组的学习
- 黑马程序员_学习笔记8_C#基础归纳之数组
- 黑马程序员_C#枚举、常量、结构体、数组的学习
- 黑马程序员_C#基础学习之第一季
- 黑马程序员_C语言学习笔记之基础
- 黑马程序员_C语言学习笔记之运算符
- 黑马程序员_C语言学习笔记之基本程序结构
- 黑马程序员_C语言学习笔记之指针基础
- 黑马程序员_C语言_数组
- 黑马程序员_C语言数组的总结
- 黑马程序员_C#代码快速注释。
- 黑马程序员_C#代码的调试问题
- 黑马程序员_C#40学习笔记1
- 黑马程序员_C#40学习笔记2
- 黑马程序员_C#面向对象学习笔记
- 黑马程序员_C#基础学习第二季
- Android平台开发-3G function porting-3G功能移植
- .Net reflector两款神器 Deblector和reflexil
- 链接和gnu C资源
- Android布局方式之表格布局管理器(TableLayout)
- private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
- 黑马程序员_C#学习之数组(代码)
- 机会只等待准备好的头脑
- JSP的重定向
- Dijkstra迪杰斯特拉 算法详细步骤及实现
- 家人的反对,我的选择
- Ubuntu基于trac的Subversion的配置
- 【酷游vpn】介绍一款很实用的网络加速器VPN
- linux技巧收集
- 单片机单串口简单通信程序