Advertisement
Five_NT

[WFA] Nr format cu cifrele maxime din 3 numere

Jan 20th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace aps
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.  
  16.         private Int32 cifra(Int32 x)
  17.         {
  18.             int cm = x%10;
  19.             while (x != 0)
  20.             {
  21.                 int c = x % 10;
  22.                 if (cm < c) cm = c;
  23.                 x = x / 10;
  24.             }
  25.             return cm;
  26.         }
  27.  
  28.         public Form1()
  29.         {
  30.             InitializeComponent();
  31.         }
  32.  
  33.         private void b_3_Click(object sender, EventArgs e)
  34.         {
  35.             this.Close();
  36.         }
  37.  
  38.         private void b_2_Click(object sender, EventArgs e)
  39.         {
  40.             Int32 nr1 = Convert.ToInt32(tb_1.Text);
  41.             Int32 nr2 = Convert.ToInt32(tb_2.Text);
  42.             Int32 nr3 = Convert.ToInt32(tb_3.Text);
  43.             int numar = cifra(nr1) * 100 + cifra(nr2) * 10 + cifra(nr3);
  44.  
  45.             tb_4.Text = Convert.ToString(numar);
  46.         }
  47.  
  48.         private void b_1_Click(object sender, EventArgs e)
  49.         {
  50.             tb_1.Text = "";
  51.             tb_2.Text = "";
  52.             tb_3.Text = "";
  53.             tb_4.Text = "";
  54.         }
  55.  
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement