C# – Ciferný součet

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 cifernySoucet
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnVypočet_Click(object sender, EventArgs e)
        {
            int x = Convert.ToInt32(vstup.Text);

            int y = 0;

            while(x > 0)
            {
                y = y + x % 10;
                x = x / 10;
            }
            vystup2.Text = y.ToString();
        }
    }
}

(12)

Sdílet na

FacebookTwitterGoogleTumblrLinkedInRedditPinterest


Napsat komentář