Advertisement
keero

f

Jun 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 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 MiningCoins_Broken
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14.  
  15. string decrypted = "";
  16. float totalValue = 0;
  17. float currentValue = 0;
  18.  
  19.  
  20. for (int i = 1; i <= n; i++)
  21. {
  22. int number = int.Parse(Console.ReadLine());
  23.  
  24. int digit1 = number / 100;
  25. int digit2 = (number % 100) / 10;
  26. int digit3 = number % 10;
  27.  
  28. currentValue = (digit1 + digit2 + digit3) / (float)n;
  29. totalValue = totalValue + currentValue;
  30.  
  31.  
  32. int ASCIIcode = 0;
  33.  
  34.  
  35. if (i % 2 == 0)
  36. {
  37. ASCIIcode = ((digit1 * 10) + digit3) + digit2;
  38. }
  39. else
  40. {
  41. ASCIIcode = ((digit1 * 10) + digit3) - digit2;
  42. }
  43.  
  44. if ((ASCIIcode >= 65 && ASCIIcode <= 90)
  45. || (ASCIIcode >= 97 && ASCIIcode <= 122))
  46. {
  47. decrypted += (char)ASCIIcode;
  48. }
  49. }
  50.  
  51.  
  52. Console.WriteLine("Message: {0}", decrypted);
  53. Console.WriteLine("Value: {0:F7}", totalValue);
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement