Advertisement
GraionDilach

Számjegyfordító

Nov 7th, 2011
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication11
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int a, b=0;
  13.             Console.Write("Kérem a számot: ");
  14.             a = int.Parse(Console.ReadLine());
  15.             do{         //átfordítom (oszt tízzel, maradékot szoroz tízzel
  16.                 b = b * 10;
  17.                 int maradek = a % 10;
  18.                 a = a / 10;
  19.                 b = b + maradek;
  20.             } while (a!=0);
  21.  
  22.             Console.WriteLine("A fordítottja: " + b);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement