lwj_C#_类的属性,方法参数 举例习题
来源:互联网 发布:软件服务龙头股 编辑:程序博客网 时间:2024/04/30 21:26
// public class Hero
// {
// public string name;
// //字段
// private int age;
// //属性 //属性里面不要使用属性本身;
// public int Age{
// get{
// return age;
// }
// set{ //可以在这里面操作 分支语句if
// age = value;//只有set里面有value;
// }
// }
// public void Change(int[]array){
// array [0] = 4;
// }
//
// //排序
// //冒泡排序
// public void Sort(int[]array){
// for (int i = 0; i < array .Length - 1; i++) {
// for (int j = 0; j < array.Length - i - 1; j++) {
// if (array[j] > array[j + 1]) {
// int temp = array [j];
// array[j] = array[j + 1];
// array[j + 1] = temp;
// }
// }
// }
// }
//
// //选择排序
// public void Sort1(int[]array){
// for (int i = 0; i < array.Length - 1; i++) {
// int min = array [i];
// int minIdex = 0;
// for (int j = i + 1; j < array.Length; j++) {
// if (min > array[j]) {
// min = array [j];
// minIdex = j;
// }
// }
// array[minIdex] = array [i];
// array[i] = min;
// }
// }
//
// //方法参数
// //引用参数 ref 调用时也要加ref; 传递前要赋值 初始值;
// public void Swap(ref int []x, ref int[] y){
// int[] temp= x;
// x = y;
// y = temp;
//
//
// }
//
// //输出参数 out out传递前可以没有值; 可以返回x y;
// public int Cal(int a ,int b, out int x, out int y){
// x = a + b;
// y = a - b;
// return x * y;
// }
//
// //params 必须时一维数组 输入任意个数的参数;
// public float Avg(params int[] array){
// int sum = 0;
// foreach (int a in array) {
// sum += a;
// }
// return sum / array.Length;
// }
//
// //三个数从小到大排序
// public void Max(ref int a, ref int b, ref int c){
// int max = (a > b ? a : b) > c ? (a > b ? a : b) : c;
// int min = (a < b ? a : b) < c ? (a < b ? a : b) : c;
// int mid = (a + b + c) - max - min;
// a = min; b = mid; c = max;
// //方法二
//// if (a < b) {
//// int temp = a;
//// a = b;
//// b = temp;
//// }
//// if (a > c) {
//// int temp = a;
//// a = c;
//// c = temp;
//// }
//// if (b > c) {
//// int temp = b;
//// b = c;
//// c = temp;
//// }
//
// }
//
// //作业求和 数组奇数位为负数;
// public int Sum(params int [] array){
// int sum = 0;
// for (int i = 0; i < array.Length; i++) {
// if (i % 2 != 0) {
// array [i] = -array [i];
// }
// sum += array [i];
// }
// return sum;
// }
// }
// {
// public string name;
// //字段
// private int age;
// //属性 //属性里面不要使用属性本身;
// public int Age{
// get{
// return age;
// }
// set{ //可以在这里面操作 分支语句if
// age = value;//只有set里面有value;
// }
// }
// public void Change(int[]array){
// array [0] = 4;
// }
//
// //排序
// //冒泡排序
// public void Sort(int[]array){
// for (int i = 0; i < array .Length - 1; i++) {
// for (int j = 0; j < array.Length - i - 1; j++) {
// if (array[j] > array[j + 1]) {
// int temp = array [j];
// array[j] = array[j + 1];
// array[j + 1] = temp;
// }
// }
// }
// }
//
// //选择排序
// public void Sort1(int[]array){
// for (int i = 0; i < array.Length - 1; i++) {
// int min = array [i];
// int minIdex = 0;
// for (int j = i + 1; j < array.Length; j++) {
// if (min > array[j]) {
// min = array [j];
// minIdex = j;
// }
// }
// array[minIdex] = array [i];
// array[i] = min;
// }
// }
//
// //方法参数
// //引用参数 ref 调用时也要加ref; 传递前要赋值 初始值;
// public void Swap(ref int []x, ref int[] y){
// int[] temp= x;
// x = y;
// y = temp;
//
//
// }
//
// //输出参数 out out传递前可以没有值; 可以返回x y;
// public int Cal(int a ,int b, out int x, out int y){
// x = a + b;
// y = a - b;
// return x * y;
// }
//
// //params 必须时一维数组 输入任意个数的参数;
// public float Avg(params int[] array){
// int sum = 0;
// foreach (int a in array) {
// sum += a;
// }
// return sum / array.Length;
// }
//
// //三个数从小到大排序
// public void Max(ref int a, ref int b, ref int c){
// int max = (a > b ? a : b) > c ? (a > b ? a : b) : c;
// int min = (a < b ? a : b) < c ? (a < b ? a : b) : c;
// int mid = (a + b + c) - max - min;
// a = min; b = mid; c = max;
// //方法二
//// if (a < b) {
//// int temp = a;
//// a = b;
//// b = temp;
//// }
//// if (a > c) {
//// int temp = a;
//// a = c;
//// c = temp;
//// }
//// if (b > c) {
//// int temp = b;
//// b = c;
//// c = temp;
//// }
//
// }
//
// //作业求和 数组奇数位为负数;
// public int Sum(params int [] array){
// int sum = 0;
// for (int i = 0; i < array.Length; i++) {
// if (i % 2 != 0) {
// array [i] = -array [i];
// }
// sum += array [i];
// }
// return sum;
// }
// }
阅读全文
0 0
- lwj_C#_类的属性,方法参数 举例习题
- lwj_C#_建立一个数学MathTool类包含的方法
- lwj_C#_类的相互使用和构造方法
- lwj_C#_集合的使用、接口方法的实现;
- lwj_C#_方法重载,递归,构造
- lwj_C#_静态,单例的使用
- lwj_C#_输入年月日,写方法输出它是今年的第几天;
- lwj_C#_string类方法 可变字符串
- lwj_C#_排序
- lwj_C#_作业
- lwj_C#_接口
- lwj_C#_字典
- 对象或对象数组作为方法参数_习题
- lwj_C#_周总结1
- lwj_C#_泛型使用
- lwj_C#_集合list<T>
- lwj_C#_homework get set 属性
- lwj_C#_work 字符串、类的使用和数学运算
- 小球弹跳
- 使用UE4开发VR项目_性能优化(一)_常用工具
- springMVC框架简单搭建
- 底噪计算
- HTML5新特性之文件和二进制数据的操作
- lwj_C#_类的属性,方法参数 举例习题
- Mac中vim命令
- 2007年分区联赛提高组之一 统计数字(SSL_1063)
- 开放源代码的全文检索引擎Lucene7.1.0,学习过程
- 读取日志文件——工具类
- 访问页面报了stackoverflow的异常
- 大数据量下高并发同步
- leetcode_335. Self Crossing ? 待解决
- IntelliJ IDEA上创建Maven Spring MVC项目