歡迎光臨 pure C# 技術社群. 登入註冊

pure C# 技術社群

- Microsoft .NET Framework 相關技術非官方討論社群 -

程式問題

  • 1
  • 2
  • [第1/2頁 共11項]
#1

程式問題

  • a
 0.0 (0 人評價)
我現在在寫一個程式

大概功能是
textBox1 跟 textBox2 還有 textBox3

程式開始時
會隨機抓一個字串去textBox1  但是會用*顯示
比如說抓到的是sagittarius textBox1會顯示成s**********

這時候我在textBox2輸入sagittarius的話 就會跑出對話框框說"你答對了"
要是我是輸入sagittarfffff 的話 會跑出"猜錯了!在猜一次吧"
同時間textBox1的s********** 會在隨機讓除了開的的s之外其中的*變成單字的英文
猜兩次失敗就會有三個是英文顯示 其他是*以此類推

當我猜五次了還沒猜對 就會出現對話框框說"你好笨喔!正確答案是"

然後textBox3是用來顯示textBox1的字串長度


以下是我做到卡住的地方
我真的沒辦法了 幫幫忙會的人教教我


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string[] a =  { "aries", "tarurs", "gemini", "cancer", "leo", "virgo", "libra", "scorpio", "sagittarius", "capriccrn", "aquarius", "pisces" };
            string t;
            int b;
            Random r = new Random(); //將英文重新排序

            for (int i = 0; i <= 11; i++)
            {
                //隨機產生以上十二個單字
                b = r.Next(12);
                t = a[i];
                a[i] = a[b];
                a[b] = t;
                textBox1.Text = a[b];

            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string c;
            int a = 0, b = 0;
           
            c = textBox2.Text;
           
            for (int i = 0; i <= 11; i++)
            {
                for (int j = 0; j <= 11; i++)
                {
                    if (textBox1.Text == textBox2.Text)
                    {
                        
                    }
 
                }

                if (textBox1.Text[i] == textBox2.Text[i])
                {
                    
                }


            }


           
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}






  • 回覆
  • |
  • 引用
  • |
  • 編輯
  • |
  • 私人訊息


贊助商連結

#2

Re: 程式問題

  • a
 0.0 (0 人評價)
引用 的文章:
以下是我做到卡住的地方
我真的沒辦法了 幫幫忙會的人教教我

是編譯會出錯還是有什麼其它問題
你是卡在哪要講清楚

  • 回覆
  • |
  • 引用
  • |
  • 編輯
  • |
  • 私人訊息

#3

Re: 程式問題

  • a
 0.0 (0 人評價)
我不知道該怎麼做 才能讓textBox1上的英文是這樣出現  "s**********"

還有我不知道要怎麼讓她在 猜錯的時候 隨機的讓其他*號的英文 變成正常的英文


式過滿多方式的 可是..都沒辦法解決

  • 回覆
  • |
  • 引用
  • |
  • 編輯
  • |
  • 私人訊息

#4

Re: 程式問題

  • a
 0.0 (0 人評價)
不是直接讓 textBox1.Text = "s**********"; 就好了嗎
還是我會錯意了????

  • 回覆
  • |
  • 引用
  • |
  • 編輯
  • |
  • 私人訊息

#5

Re: 程式問題

  • a
 0.0 (0 人評價)

當然不是

我的tbox 是從 string[] a =  { "aries", "tarurs", "gemini", "cancer", "leo", "virgo", "libra", "scorpio", "sagittarius", "capriccrn", "aquarius", "pisces" };

隨機抓的

我是讓他 抓 玩之後 除了第一碼之外 其他都是由*號顯示

每當我猜一次 要是猜錯 *號就會多一個

對的話就會直接說 答對了


  • 回覆
  • |
  • 引用
  • |
  • 編輯
  • |
  • 私人訊息

#6

Re: 程式問題

  • a
 0.0 (0 人評價)

第一個問題還滿簡單的
string str = a[b].Substring(0,1);
str = str.PadRight(a[b].length,'*');

至於第二個問題好像也不太難...
不過懶的寫了


  • 回覆
  • |
  • 引用
  • |
  • 編輯
  • |
  • 私人訊息

#7

Re: 程式問題

  • a
 0.0 (0 人評價)

第一個問題還滿簡單的
string str = a[b].Substring(0,1);
str = str.PadRight(a[b].length,'*');

至於第二個問題好像也不太難...
不過懶的寫了


--------------------------------

我試過了..不行


  • 回覆
  • |
  • 引用
  • |
  • 編輯
  • |
  • 私人訊息


贊助商連結

#8

Re: 程式問題

  • a
 0.0 (0 人評價)
我也試過了 明明就可以
我都已經寫出你所需要的程式
才跑上來PO的

  • 回覆
  • |
  • 引用
  • |
  • 編輯
  • |
  • 私人訊息
  • 1
  • 2
  • [第1/2頁 共11項]