Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace kerto_teht
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int luku = 0;
  14.  
  15.  
  16. Console.WriteLine("luku -1 lopettaa loopin. \n\nAnna luku 1 - 20 väliltä");
  17. // lisätään 1 tyhjä väli selkeyttämisen kannalta
  18. Console.WriteLine();
  19.  
  20. do
  21. {
  22. Console.WriteLine("Anna luku: ");
  23. luku = int.Parse(Console.ReadLine());
  24.  
  25.  
  26.  
  27. if (luku >= 1 && luku <= 20)
  28. {
  29.  
  30. for (int a = 1; a <= luku; a++)
  31. {
  32.  
  33.  
  34. for (int b = 1; b <= luku; b++)
  35. {
  36.  
  37.  
  38.  
  39. Console.Write((a * b).ToString("00 "));//tulostetaan numeron kertotaulut
  40.  
  41.  
  42. }
  43.  
  44. Console.WriteLine();
  45.  
  46.  
  47.  
  48. }
  49.  
  50.  
  51. }
  52.  
  53. if (luku < 1 || luku > 20)//poissuljetaan lukujen 1-20 ulkopuoliset luvut
  54. continue;
  55.  
  56. else
  57. continue;
  58.  
  59. }
  60.  
  61.  
  62. while (luku != -1);
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement