Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 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 Task_1._3
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Input number a: ");
  14. string a = Console.ReadLine();
  15. int w = 0;
  16. int z = 10;
  17. int[] b = new int[a.Length];
  18. for (int i = 0; i < a.Length; i++)
  19. {
  20. b[i] = Convert.ToInt32(a.Substring(i, 1));
  21. w = w + b[i] * z;
  22. z--;
  23. }
  24. int x;
  25. if (w % 11 != 0)
  26. {
  27. x = (w / 11 + 1) * 11 - w;
  28.  
  29. }
  30. else
  31. {
  32. x = 0;
  33. }
  34. if (x == 10)
  35. { Console.WriteLine(a + 'X'); }
  36. else
  37. {
  38. Console.WriteLine(a + x);
  39. }
  40. Console.ReadLine();
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement