Advertisement
chipsi2

חזרה למבחן

Feb 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1.  //1
  2.         //public static int HighDog (int x,char h)
  3.         //{
  4.         //    int y = 0, total;
  5.         //    if (h == 's')
  6.         //        y = 4;
  7.         //    if (h == 'm')
  8.         //        y = 8;
  9.         //    if (h == 'b')
  10.         //        y = 12;
  11.         //    total = y * x;
  12.         //    return total;
  13.         //}
  14.         public static int SumDigits(int num)
  15.         {
  16.             int sum = 0;
  17.             while (num > 0)
  18.                 sum += num % 10;
  19.             num /= num;
  20.             return sum;
  21.         }
  22.         static void Main(string[] args)
  23.         {
  24.             //1
  25.             //int x = int.Parse(Console.ReadLine());
  26.             //char high = char.Parse(Console.ReadLine());
  27.             //while (high!=' ')
  28.             //{
  29.             //    Console.WriteLine("total :"+HighDog(x, high));
  30.             //     x = int.Parse(Console.ReadLine());
  31.             //    high = char.Parse(Console.ReadLine());
  32.             //}
  33.             int x=0,y=0;
  34.             int num = int.Parse(Console.ReadLine());
  35.             x = SumDigits(num);
  36.             if (x > 9)
  37.             {
  38.                 while (!(x < 10))
  39.                 {
  40.                     y= SumDigits(x);
  41.                 }
  42.                 if (y == 9)
  43.                     Console.WriteLine("good in 9");
  44.                 else Console.WriteLine("not good");
  45.             }
  46.             else
  47.             if (x == 9)
  48.                 Console.WriteLine("good in 9");
  49.             else Console.WriteLine("not good");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement