Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Római
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- int szam;
- string romai;
- private void btRomai_Click(object sender, EventArgs e)
- {
- romai = null;
- tbRomai.Clear();
- szam = Convert.ToInt32(tbSzam.Text);
- do
- {
- if (szam >= 1000)
- {
- romai += 'M';
- szam -= 1000;
- }
- else if (szam >= 900)
- {
- romai += "CM";
- szam -= 900;
- }
- else if (szam >= 500)
- {
- romai += 'D';
- szam -= 500;
- }
- else if (szam >= 400)
- {
- romai += "CD";
- szam -= 400;
- }
- else if (szam >= 100)
- {
- romai += 'C';
- szam -= 100;
- }
- else if (szam >= 90)
- {
- romai += "XC";
- szam -= 90;
- }
- else if (szam >= 50)
- {
- romai += 'L';
- szam -= 50;
- }
- else if (szam >= 40)
- {
- romai += "XL";
- szam -= 40;
- }
- else if (szam >= 10)
- {
- romai += 'X';
- szam -= 10;
- }
- else if (szam >= 9)
- {
- romai += "IX";
- szam -= 9;
- }
- else if (szam >= 5)
- {
- romai += 'V';
- szam -= 5;
- }
- else if (szam >= 4)
- {
- romai += "IV";
- szam -= 4;
- }
- else if (szam >= 1)
- {
- romai += 'I';
- szam -= 1;
- }
- } while (szam != 0);
- tbRomai.Text = romai;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement