Advertisement
Guest User

Untitled

a guest
Dec 29th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _29_12class
  8. {
  9. class Program
  10. {
  11. static int num;
  12. static bool flagIsDouble;
  13.  
  14. static void Main(string[] args)
  15. {
  16. Console.WriteLine("Please enter a number:");
  17. string inputFromUser;
  18. Console.ForegroundColor = ConsoleColor.Blue;
  19. inputFromUser = Console.ReadLine();
  20. num = Int32.Parse(inputFromUser);
  21. //isDouble();
  22. func1();
  23.  
  24. Console.ReadLine();
  25. }
  26. static void func1()
  27. {
  28. int tmp = num;
  29. for (int i = tmp; i > 0; i--)
  30. {
  31. Console.WriteLine(num);
  32. isDouble();
  33. if (flagIsDouble == true)
  34. {
  35. if (Console.ForegroundColor == ConsoleColor.Red)
  36. {
  37. Console.ForegroundColor = ConsoleColor.Blue;
  38. }
  39. else
  40. {
  41. Console.ForegroundColor = ConsoleColor.Red;
  42. }
  43.  
  44. }
  45. num--;
  46.  
  47. }
  48. }
  49. static void isDouble()
  50. {
  51. if (num%2==0 && num!=1)
  52. {
  53. Console.WriteLine("Is double");
  54. flagIsDouble = true;
  55. }
  56. else
  57. {
  58. Console.WriteLine("Is not double");
  59. flagIsDouble = false;
  60. }
  61.  
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement