zoukankan      html  css  js  c++  java
  • C# 作业

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            private int left = 0;
            private int right = 0;
            private Random rd = new Random();
            int num = 0;
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
    
            }
    
            private void label1_Click(object sender, EventArgs e){  }
            private void label3_Click(object sender, EventArgs e){  }
            private void label5_Click(object sender, EventArgs e){ }
            private void label7_Click(object sender, EventArgs e){ }
            private void label8_Click(object sender, EventArgs e){}
            private void Form1_Load(object sender, EventArgs e)
            {
                left = rd.Next(1, 1000);
                right = rd.Next(1, 1000);
                label1.Text = left.ToString();
                label3.Text = right.ToString();
            }
            
            private void button1_Click_1(object sender, EventArgs e)
            {
                string strResult = textBox1.Text;
                int val;
                try
                {
                      val= int.Parse(strResult);
                }
                catch(System.FormatException)
                {
                    label5.Text = " 格式不对 请重新输入  "; return;
                }
                if (left + right == val)
                {
                    label5.Text = " you are right ";
                    num++;
                    label8.Text = num.ToString();
                }
                else
                {
                    label5.Text = " you are wrong ";
                }
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                left = rd.Next(1, 1000);
                right = rd.Next(1, 1000);
                label1.Text = left.ToString();
                label3.Text = right.ToString();
                textBox1.Text = "";
                label5.Text = "";
            }    
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication1
    {
        struct SomeVal { public Int32 x; }
        class SomeRef { public Int32 x; }
        class Program
        {
            static void Main(string[] args)
            {
                
     
        
                SomeVal v1 = new SomeVal() ; // 分配到    堆 (堆/栈)
                //Console.WriteLine(v1.x); //能运行吗?  不能        
                v1 = new SomeVal();
                Console.WriteLine(v1.x); //输出  0     
                v1.x =5; 
                Console.WriteLine(v1.x); //输出   5   
    
                SomeRef r1=new SomeRef(); 
               // Console.WriteLine(r1.x); //能运行吗?   不能    
                // 分配到    栈 (堆/栈)
                Console.WriteLine(r1.x); //输出    0  
                r1.x =5;
                Console.WriteLine(r1.x); //输出     5 
    
                SomeVal v2 = v1;
                SomeRef r2 = r1;
                v1.x = 9;
                r1.x = 8;
                Console.WriteLine(r1.x); //输出      8
                Console.WriteLine(r2.x); //输出      8
                Console.WriteLine(v1.x); //输出      9
                Console.WriteLine(v2.x); //输出      5
    
                Console.ReadKey();
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                string str=Console.ReadLine();
                string sss="";
                int key= Console.ReadKey().KeyChar;
                for (int i = 0; i < str.Length; i++)
                {
                    sss=sss+ (char)( (int)(str[i]) ^ key);
                }
                Console.WriteLine(sss);
                Console.WriteLine(str);
                Console.ReadKey();
            }
        }
    }
  • 相关阅读:
    【解题报告】NOIP2018
    【解题报告】NOIP2013
    【解题报告】NOIP2014
    【解题报告】NOIP2015
    【解题报告】NOIP2016
    【解题报告】CSPS2020
    【全程NOIP计划】初级数据结构1
    如何通过一个结构体成员变量的地址找到该结构体的首地址?[备忘]
    IGT笔试题,正整数N等于M个不同的正整数之和的问题
    Mac下Perl脚本如何运行
  • 原文地址:https://www.cnblogs.com/Andromeda-Galaxy/p/10552325.html
Copyright © 2011-2022 走看看