Advertisement
GraionDilach

A és B közti héttel oszthatók

Oct 10th, 2011
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication5
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int a;
  13.             do{
  14.                 Console.WriteLine("\nKérem az első egész számot:");
  15.                 a = int.Parse(Console.ReadLine());
  16.             } while(a <= 0);
  17.  
  18.             int b;
  19.             do
  20.             {
  21.                 Console.WriteLine("\nKérem a második egész számot:");
  22.                 b = int.Parse(Console.ReadLine());
  23.             } while (b <= 0);
  24.  
  25.             Console.WriteLine("\n7-tel osztható közöttük");
  26.  
  27.             if (b > a)
  28.             {
  29.                 for (b--; b != a; b--)
  30.                 {
  31.                     if (b % 7 == 0)
  32.                     {
  33.                         Console.WriteLine(b);
  34.                     }
  35.  
  36.                 }
  37.             }
  38.             else
  39.             {
  40.                 for (a--; a != b; a--)
  41.                 {
  42.                     if (a % 7 == 0)
  43.                     {
  44.                         Console.WriteLine(a);
  45.                     }
  46.  
  47.                 }
  48.             }
  49.  
  50.            
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement