Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Toistorakennetehtava
- {
- class Program
- {
- static void Main(string[] args)
- {
- int luku;
- Console.WriteLine("Anna valintasi: ");
- int.TryParse(Console.ReadLine(), out luku);
- int i, n, kertoma;
- while (luku == 1)
- {
- Console.Write("Anna kokonaisluku, jonka kertoman tahdot: ");
- int.TryParse(Console.ReadLine(), out n);
- kertoma = n;
- i = n - 1;
- while (i > 0)
- {
- kertoma *= i;
- i--;
- }
- Console.WriteLine("{0}! = {1}", n, kertoma);
- Console.WriteLine("Anna valintasi: ");
- int.TryParse(Console.ReadLine(), out luku);
- }
- while (luku == 0)
- {
- Console.WriteLine("Ohjelma lopetetaan");
- Environment.Exit(0);
- }
- while (luku >= 1)
- {
- Console.WriteLine("Annoit väärän valinnan!");
- Console.WriteLine("Anna valintasi: ");
- int.TryParse(Console.ReadLine(), out luku);
- while (luku == 1)
- {
- Console.Write("Anna kokonaisluku, jonka kertoman tahdot: ");
- int.TryParse(Console.ReadLine(), out n);
- kertoma = n;
- i = n - 1;
- while (i > 0)
- {
- kertoma *= i;
- i--;
- }
- Console.WriteLine("{0}! = {1}", n, kertoma);
- Console.WriteLine("Anna valintasi: ");
- int.TryParse(Console.ReadLine(), out luku);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement