c#经典程序.docx_第1页
c#经典程序.docx_第2页
c#经典程序.docx_第3页
c#经典程序.docx_第4页
c#经典程序.docx_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication3 /*class Program static void Main(string args) for (int i = 1; i = 9; i+) for (int j = 1; j = i; j+) Console.Write(0*1=2t, i, j, i * j); Console.WriteLine(n); Console.ReadKey(); */ /* class fengjie static void Main() Console.Write(输入你要分解的数字:); int p =Convert.ToInt32(Console.ReadLine(); /Console.Write(p); for(int i=2;i= a & c = A & c = 0 & c = 9) j+; else k+; Console.Write(0,1,2, i, j, k); Console.ReadKey(); */ /*class paixu static void Main() Console.WriteLine(输入你要排序数的个数); int n; n = int.Parse(Console.ReadLine(); int a = new intn; Console.WriteLine(请一次输入你要排序的数字an回车结束); string strings=new stringn; for (int i = 0; i n; i+) stringsi = Console.ReadLine(); for (int i = 0; i n; i+) ai =Convert.ToInt32(stringsi); for (int i = 0; i = n; i+) for (int j = i + 1; j n; j+) int temp; if (ai aj) temp = aj; aj = ai; ai = temp; Console.WriteLine(排序的结果为:); for (int i = 0; i 1 ) Console.WriteLine(输入一个数字); double p = Double.Parse(Console.ReadLine(); int h = (int)p; int w; if (p - h) = 0.5) w = h + 1; else w = h; Console.WriteLine(w); Console.ReadKey(); */ /* class jisuan public static void Main() double i = 1; double sum = 1; while (i =99) sum =sum+i / (i + 1); i+; Console.WriteLine(sum); Console.ReadKey(); */ /* struct student public int age; public string name; public string address; ; class shuz public static void Main() student sd; sd.age = 19; = xiaoxiao; sd.address = gansu; Console.WriteLine(0,1,2, sd.age, , sd.address); Console.ReadKey(); */ /* class sum public static void Main() int i=0, sum; sum = 0; do sum += i; i+; while (i = 100); Console.WriteLine(sum); Console.ReadKey(); */ /*class bijiao public static void Main() Console.WriteLine(输入两个数字); double a = double.Parse(Console.ReadLine(); double b = double.Parse(Console.ReadLine(); double min = Math.Min(a, b); double max = Math.Max(a, b); Console.WriteLine(min=0,max=1, min, max); Console.ReadKey(); */ /* class pingfanghe public static void Main() double sum = 0; int i = 0; while (i 10) sum += Math.Pow(i, 2); i+; Console.WriteLine(sum); Console.ReadKey(); */ /* class 水仙花 public static void Main() int i, j, k;int h=0; for (int a = 100; a 1000; a+) i = a / 100; j = a / 10%10; k = a %10; if(a=Math.Pow(i,3)+Math.Pow(j,3)+Math.Pow(k,3) Console.Write( +a); h+; if (h % 5 = 0) Console.WriteLine(n); Console.ReadKey(); */ /*class 素数 public static void Main() int i, j; int d = 0; bool flag; for (i = 2; i 1000; i+) flag = true; for (j = 2; j i / 2; j+) if (i % j = 0) flag = false; break; if (flag = true) Console.Write( + i); d+; if (d % 5 = 0) Console.WriteLine(n); Console.ReadKey(); */ /*class jiafa public static void Main() int i = 0, j = 0, sum = 0; int h = 0; while (i 100) while (j 100) h+= j; j+; sum += j; i+; Console.WriteLine(sum); Console.ReadKey(); */ /* public struct admin public string name; public string possword; class 登陆系统 public static void Main() admin a = new admin(); int i = 0; = 李文童; a.possword = 198722; string names, posswords; while (i 3) Console.WriteLine(请输入用户名:); names = Console.ReadLine(); Console.WriteLine(请输入密码:); posswords = Console.ReadLine(); if ( = names & a.possword = posswords) Console.WriteLine(登陆中 ); else Console.WriteLine(用户名或者密码错误,请重新输入); i+; Console.ReadKey(); */ /*class he public static void Main() double s = 0; double i = 1; while (s 2000) s =s+ Math.Pow(i, 2); i+; Console.WriteLine(i); Console.ReadKey(); */ /* class 斐波那契数列 public static void Main() int f1 = 0; int f2 = 1; int f3; while (f1 = 0) double d = (-b) + Math.Sqrt(Math.Pow(b, 2) - 4 * a * c) / (2 * a); double e = (-b) - Math.Sqrt(Math.Pow(b, 2) - 4 * a * c) / (2 * a); Console.Write(这个一一元二次方程的解是 + d + + e); else Console.Write(不存在); Console.ReadKey(); */ /* class sushu /1-200之内的素数 public static void Main() int i = 2, j ; int d = 0; bool b; while (i 200) b = true; j = 2; while (j =i/2) if (i % j = 0) b = false; break; j+; if (b =true) Console.Write( + i); d+; if (d % 5 = 0) Console.WriteLine(n); i+; Console.WriteLine( + d); Console.ReadKey(); */ /* class bianhu public static void Main() Console.WriteLine(输入一个数字); int a = (int)double.Parse(Console.ReadLine(); int b = a % 10; int c = (int)a /10%10 ; int d = a /100; Console.WriteLine(0,1,2, b, c, d); Console.ReadKey(); */ / /* /素数 /* / /* class sushu public static void Main() int i = 2; int j; int d = 0; bool b; while (i 200) b = true; j = 2; while (j = i / 2) if (i % j = 0) b = false; break; j+; if (b = true) Console.Write( + i); d+; if (d % 5 = 0) Console.WriteLine(n); i+; Console.Write(d); Console.ReadKey(); */ /* class sushu public static void Main() bool b; int d=0; for (int i = 2; i = 200; i+) b = true; for (int j = 2; j = i / 2; j+) if (i % j = 0) b = false; break; if (b = true) Console.Write( + i); d+; if (d % 5 = 0) Console.WriteLine(n); Console.WriteLine(d); Console.ReadKey(); */ / /* /经典算法 鸡蛋问题 /* / /* class dan public static void Main() int num=5;/最大的是四个四个数 所以余一 取得最小值是 5; while (num 1000) if (num % 3 = 1 & num % 4 = 1 & num % 2 = 1) Console.Write( + num); num+; Console.ReadKey(); */ / /* /1-200奇数和 /* / /*class ji public static void Main() int sum = 0; int h = 0; for (int i = 0; i = 200; i+) if (i % 2 = 0) continue; else sum += i; h+; if(i%2!=0) sum+=i; Console.Write( + sum + + h); Console.ReadKey(); */ / /* /九九乘法表 /* / /* class s public static void Main() for (int i =1 ; i=9; i+) for (int j = 1; j=i; j+) Console.Write( +i + * + j + = + i * j); Console.WriteLine(n); Console.ReadKey(); */ / / 圣诞树程序 / /* class ChristmasTree static void Main(string args) Console.WriteLine(请输入一个数字,然后回车); string str = Console.ReadLine(); int c = Convert.ToInt32(str); /第一部分的图形 for (int i = 1; i = c; i+) for (int k = 0; k 2 * c - i; k+) Console.Write( ); for (int j = 1; j = 2 * i - 1; j+) Console.Write(*); Console.WriteLine(); /第二部分的图形 for (int m = 3; m = c; m+) for (int b = 0; b 2 * c - m; b+) Console.Write( ); for (int n = 1; n = 2 * m - 1; n+) Console.Write(*); Console.WriteLine(); if (m = c) for (m = c - 2; m c; m+) Console.Write( ); for (m = 0; m 3 * c; m+) Console.Write(*); Console.WriteLine(); /第三部分图形 for (int m = c - 2; m c; m+) for (int b = 1; b 2 * c; b+) Console.Write( ); for (int n = 1; n = 2; n+) Console.Write(*); Console.WriteLine(); Console.Write(请输入你想输出的字符串,按回车确认 + n); string h = Console.ReadLine(); Console.Write(你输入的字符串为: + h + n); */ / /倒三角程序 / /*class Trigon public static void Main() for (int i = 1, j = 0; i = 9; i+) for (j = 0; j = i; j+) Console.Write( ); for (int h =0 ; h =2*(9-i); h+) Console.Write(*); Console.WriteLine(); Console.ReadKey(); */ / /while循环输入十个数字 并比较大小 / /*class puts public static void Main() int d; int i = 0; int max1 = 0, s = 0; while (i 10) Console.Write(请输入第 + (i+1 )+ 个数:); d = int.Parse(Console.ReadLine(); if (max1 max1) / / max1 = s; / i+; Console.Write(最大数是: + max1); */ / /数组问题 数学最高成绩 / /*class math1 public static void Main() double math = new double10; Console.WriteLine(请输入10个同学的数学成绩n); double sum = 0; for (int i = 0; i math.Length; i+) Console.Write(第 + (i + 1) + 个:); mathi = double.Parse(Console.ReadLine(); sum += mathi; double

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论