作业四-结队编程项目-四则运算
四則運算-結隊編程
隊友:鄭都都
學號:130201239
博客地址:http://www.cnblogs.com/dudu-27/
作業要求:
基本功能要求:
1) 實現一個帶有用戶界面的四則運算。
2) 生成的題目不能重復。
3) 支持負數,例如-1,-1/2,-3‘4/5等。
需要支持的基本設定參數
1) 題目的數量(個人項目的要求)
2) 數值的范圍(個人項目的要求)
3) 題目中最多幾個運算符
4) 題目中或運算過程中有無有分數(比如進行整數除法的時候不能除盡)
5) 題目中是否有乘除法
6) 題目中是否有括號
7) 題目中或運算過程中有無負數
2.附加題----能把四則運算計算的功能封裝起來,通過測試程序和API接口測試其簡單的加法功能。(10分)
??????? 注意:?博客中需要給出單元測試的步驟及截圖
完成狀態:
題目上述要求都已完成,但附加題中只是把四則運算的功能進行簡單封裝。
負責內容:
負責的內容都差不多,畢竟都是在一起共同花時間完成的,每個部分的程序設計都有參加,但是括號功能沒能過多的去寫代碼。
優缺點:
優點:
1、可以耐心的去完成自己的任務,并且可以再出現問題是及時解決。
2、能夠把自己之前學到的知識充分的運用到編程中,并且會積極思考現在以及將要面臨的問題。
3、有良好的溝通與解釋能力,能與隊友有好的溝通,并為他解決不懂的問題。
缺點:
1、對待問題有時缺乏積極性,不能積極的對待某個問題的解決。
2、在編程時知識掌握不牢固,有時會感到知識的匱乏,還需向網絡求助。
團隊合作的優缺點:
優點:
能夠增加自己的溝通和交往能力,激發個人的想象力,使自己的想法在隊友的幫助下邊的更好,更完善;再者,一個優秀的團隊能高效快速的解決問題,比一個人更加迅速。
缺點:
有時會在一個問題上產生分歧,會浪費時間。不同人打的代碼不一致,在修改錯誤時會很麻煩。
照片與成果:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;namespace 四則運算 {public partial class Form1 : Form{int i, j;char[] fh = { '+', '-', '×', '÷' };// char[] fs = { ' ', '-' };public Form1(){InitializeComponent();}static int GetRandomSeed() //隨機數種子,解決隨機數一致問題 {byte[] bytes = new byte[4];System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider();rng.GetBytes(bytes);return BitConverter.ToInt32(bytes, 0);}private void button1_Click(object sender, EventArgs e){i = int.Parse(textBox1.Text);//獲取題數j = int.Parse(textBox2.Text);//獲取運算符數int m = 0;Random rd = new Random(GetRandomSeed());int n=1;for (int a = 0; a < i; a++){if (checkBox2.Checked == true){m = input_qkh(m, n);input_num();for (int b = 0; b < j; b++){input_fh();//input_fs();if (b < j - n) { m = input_qkh(m, n); }input_num();m = input_hkh(m, n);//input(" "); }input("=\n");}else {input_num();for (int b = 0; b < j; b++){input_fh();// input_fs(); input_num();// input(" "); }input("=\n");}}}public void input_num(){int a = int.Parse(textBox4.Text);int b = int.Parse(textBox5.Text);if (checkBox3.Checked == true){Random rd = new Random(GetRandomSeed());int c = rd.Next(2);int num1 = rd.Next(a, b + 1);int num2 = rd.Next(0, b + 1);switch (c){case 0: {input(num1.ToString());input("/");input(num2.ToString());} break;case 1: input(num1.ToString()); break;}}else{Random rd = new Random(GetRandomSeed());int num1 = rd.Next(a, b + 1);input(num1.ToString());}}public int input_qkh(int m,int n)//(前括號)m為判定有無前括號,n為后括號添加位置 {Random rd = new Random(GetRandomSeed());if(m == 0) //判定有無前括號 {int a = rd.Next(2);if (a == 0) //隨機概率添加前括號{ input("(");m = 1;}}else{}// input("m=" + m.ToString());return m;}public int input_hkh(int m, int n)//(后括號)m為判定有無前括號,n為后括號添加位置 {Random rd = new Random(GetRandomSeed());if (m == 0) //判定有無前括號 {}else{if (m == n + 1){input(")");m = 0;}else{ m++; }}// input("m="+m.ToString());return m;}/*public void input_fs(){if (checkBox1.Checked == true){Random rd = new Random(GetRandomSeed());input(fs[rd.Next(2)].ToString());//符號}else {input(" ");}}*/public void input_fh(){if (checkBox4.Checked == true){Random rd = new Random(GetRandomSeed());input(fh[rd.Next(4)].ToString());//符號 }else {Random rd = new Random(GetRandomSeed());input(fh[rd.Next(2)].ToString());//符號 }}private void button2_Click(object sender, EventArgs e){textBox3.Text = "";textBox1.Text = "";textBox2.Text = "";textBox4.Text = "";textBox5.Text = "";}public void input(string t){textBox3.AppendText(t);}} }
?
轉載于:https://www.cnblogs.com/zzkmark/p/5361038.html
總結
以上是生活随笔為你收集整理的作业四-结队编程项目-四则运算的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Makefile 7——自动生成依赖关
- 下一篇: PS把一张白色背景的图片设为透明