1.
新建一个窗体,上面加一个文本框和一个按钮,当点击按钮,要求将删除输入字符中重复的字符;
2.
显示1~1000之间的偶数,并计算它们个数和它们的和以及它们的乘积
3.
要求输入20个数字,对20个数字进行排序并输出.
4.
新建一个窗口, 上面加两个文本框和一个按钮, 点击按钮, 
第一个文本框输入的内容 为 A
第二个文本框输入的内容 为 B
查找B在A中出现的次数.

解决方案 »

  1.   

    你可以到这里看看,应该有答案的
    http://www.pcbit.com.cn
      

  2.   

    1.
    新建一个窗体,上面加一个文本框和一个按钮,当点击按钮,要求将删除输入字符中重复的字符;
    private void button1_Click(object sender, EventArgs e)
            {
                int length = this.textBox1.Text.Length;
                Hashtable ht = new Hashtable();
                ArrayList list = new ArrayList();
                for (int i = 0; i < length; i++)
                {
                    if (!ht.Contains(textBox1.Text.Substring(i, 1)))
                    {
                        ht.Add(textBox1.Text.Substring(i, 1),i);
                        list.Add(textBox1.Text.Substring(i, 1));
                    }
                }
                string s = "";
                for (int i = 0; i < list.Count; i++)
                {
                    s += list[i];
                }
                this.textBox1.Text = s;        }
    --------------------------------------------------------------------
    此程序效率并不高,嘿嘿,谁叫你自己不努力呢...
    2.
    显示1~1000之间的偶数,并计算它们个数和它们的和以及它们的乘积private void button2_Click(object sender, EventArgs e)
            {
                int sum = 0;
                int count = 0;
                long mulSum = 1;            for (int i = 1; i <= 20; i++)
                {
                    if (i % 2 == 0)
                    {
                        count++;
                        sum += i;
                        mulSum *= i;//注:此处最后将得出错误结果,想一下为什么?
                              //500个数相乘????用什么装?大整数相乘..此是思路
                    }
                }
                Console.WriteLine("sum=" + sum);
                Console.WriteLine("count=" + count);
                Console.WriteLine("mulSum=" + mulSum);
            }
      

  3.   

    4.
    新建一个窗口, 上面加两个文本框和一个按钮, 点击按钮, 
    第一个文本框输入的内容 为 A
    第二个文本框输入的内容 为 B
    查找B在A中出现的次数.private void button3_Click(object sender, EventArgs e)
            {
                string a = this.textBox2.Text;
                string b = this.textBox3.Text;
                if (a.Length != 0 && b.Length != 0)
                {
                    string tempstr = a;
                    tempstr = tempstr.Replace(b, "");
                    int charcount = (a.Length - tempstr.Length);
                    int count = 0;
                    if (charcount > 0)
                        count = charcount / b.Length;                Console.WriteLine("b在a中出现了" + charcount + "次");
                }        }
    ------------------------------------------- 为什么不写第三题??啊,都叫我写了你做什么????:(
      

  4.   

    定义的类型改一下就可以了吧
    long   该成double
      

  5.   

    第一个:Button_Click事件下:
    private void button1_Click(object sender, System.EventArgs e)
    {
    ArrayList ar = new ArrayList();
    foreach(char ch in this.textBox1.Text.ToCharArray())
    {
    if(!ar.Contains(ch))
    {
    ar.Add(ch);
    }
    }
    this.textBox1.Text = "";
    foreach(object obj in ar)
    {
    this.textBox1.Text += obj.ToString();
    }
    }
    第二个://控制台程序Main()函数内部,要加System.Collections命名空间。
    ArrayList ar = new ArrayList();
    for(int i=1;i<=1000;i++)
    {
    if(i%2==1)
    {
    ar.Add(i);
    }
    }
    Console.WriteLine("个数:{0}",ar.Count);
    int k = 0;
    int m = 1;
    for(int i=0;i<ar.Count;i++)
    {
    k += Convert.ToInt32(ar[i]);
    m *= Convert.ToInt32(ar[i]);
    }
    Console.WriteLine("和:{0}\n积:{1}",k,m);
    Console.ReadLine();
    第三个:
    static void Main(string[] args)
    {
    //
    // TODO: アプリケーションを開始するコードをここに追加してください。
    //
    ArrayList ar = new ArrayList();
    string str = Console.ReadLine();
    string[] st = str.Split(new char[]{' '});
    foreach(string s in st)
    {
    ar.Add(Convert.ToInt32(s));
    }
    Console.WriteLine();
    ar.Sort();
    for(int i=0;i<ar.Count;i++)
    {
    Console.Write(ar[i]+" ");
    }
    Console.ReadLine();
    }
    第四个:
    private void button1_Click(object sender, System.EventArgs e)
    {
    int i = this.textBox2.Text.Length-this.textBox2.Text.Replace(this.textBox1.Text,"").Length;
    this.textBox3.Text = (i/this.textBox1.Text.Length).ToString();
    }//text1是对比字符串;text2是被对比字符串;text3是结果个数。
      

  6.   

    1. 
    string str = txtInput;
    ArrayList al = new ArrayList( str.Length);
    int i = ;
    while( i < str.Length )
    {
        if( al.Contains( str.Chars[i] )
             str.Remove( i,1 );
        else
            al.Add( str.Chars[i++] );
    }//完成任务了
    2.
    //乘机
    double multi = 1.0;
    //百的位数
    long int hundreds = 0;
    for( int i = 2; i <= 1000; i +=2 )
    {
       //输出
        Console.Write( i );
        multi *= i;
        if( multi >= 100 )
        {
            multi *= 0.01;
            hundreds++;
        }
    }
    //数量
    int count = 1000/2;
    int sum = (2 + 1000 ) * 500 / s
    3
    int[] aInput;
    Array.Sort( aInput as Array )
    for( int i = 0; i < aInput.Length; i ++ )
       Console.WriteLine( aInput[i] );
    4.
    string strA;
    string strB;
    string strTemp = strA.Replace( strB,"" );
    //结果出来了
    int count = ( strA.Length - strTemp.Length ) / strB.Length