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;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] DasArray = new int[1];
- int ArrayCount = 0;
- bool ell;
- int Current;
- bool superell = true;
- do
- {
- do
- {
- Console.Write("Kérem a " + (ArrayCount + 1) + ". számot: ");
- ell = int.TryParse(Console.ReadLine(), out Current);
- } while (!(ell && Current > -1));
- // } while (!ell || Current < 0);
- if (Current != 0)
- {
- Array.Resize(ref DasArray, ArrayCount + 1);
- DasArray[ArrayCount] = Current;
- ArrayCount++;
- }
- if (Current == 0 && ArrayCount == 0)
- { superell = false; }
- } while (Current != 0);
- if (superell)
- {
- for (int i = 0; i < DasArray.Length; i++)
- {
- int Sum;
- ell = HashNumber(out Sum, DasArray[i]);
- if (ell)
- {
- Console.WriteLine("A " + (i + 1) + ". szám számjegyazonossággal rendelkezik, számjegyösszege " + Sum + ".");
- }
- else
- {
- Console.WriteLine("A " + (i + 1) + ". szám számjegyazonossággal nem rendelkezik, számjegyösszege " + Sum + ".");
- }
- }
- }
- }
- static bool HashNumber (out int Sum, int Input)
- {
- int[] Numbers = new int[10];
- Sum = 0;
- do
- {
- int Temp = Input % 10;
- Sum = Sum + Temp;
- Numbers[Temp]++;
- Input = Input / 10;
- } while (Input > 0);
- for (int i = 0; i < Numbers.Length; i++)
- {
- if (Numbers[i] > 1)
- {
- return true;
- }
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement