Advertisement
abasar

arrays 13/1

Jan 13th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.50 KB | None | 0 0
  1. //#1
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace ConsoleApplication2
  8. {
  9.     class Program
  10.     {
  11.         static void Kelet(int[] a)
  12.         {
  13.             for (int i = 0; i < a.Length; i++)
  14.                 a[i] = int.Parse(Console.ReadLine());
  15.         }
  16.         static bool T37(int[] a)
  17.         {
  18.             int counter7 = 0, counter3 = 0;
  19.             for (int i = 0; i < a.Length; i++)
  20.             {
  21.                 if (a[i] % 7 == 0)
  22.                     counter7++;
  23.                 if (a[i] % 3 == 0)
  24.                     counter3++;
  25.             }
  26.             return counter3 > counter7;
  27.         }
  28.         static void Main(string[] args)
  29.         {
  30.             int[] a = new int[10];
  31.             Kelet(a);
  32.             Console.WriteLine(T37(a));
  33.         }
  34.     }
  35. }
  36.  
  37. //#2
  38. using System;
  39. using System.Collections.Generic;
  40. using System.Linq;
  41. using System.Text;
  42.  
  43. namespace ConsoleApplication2
  44. {
  45.     class Program
  46.     {
  47.         static void Kelet(int[] a)
  48.         {
  49.             for (int i = 0; i < a.Length; i++)
  50.                 a[i] = int.Parse(Console.ReadLine());
  51.         }
  52.         static int Smallest(int num)
  53.         {
  54.             int min = 0;
  55.             while (num != 0)
  56.             {
  57.                 if (num % 10 > min)
  58.                     min = num;
  59.                 num /= 10;
  60.             }
  61.             return min;
  62.         }
  63.         static int Biggest(int num)
  64.         {
  65.             int max = 10;
  66.             while (num != 0)
  67.             {
  68.                 if (num % 10 < max)
  69.                     max = num;
  70.                 num /= 10;
  71.             }
  72.             return max;
  73.         }
  74.         static void Main(string[] args)
  75.         {
  76.             int[] a = new int[10];
  77.             Kelet(a);
  78.             for (int i = 0; i < a.Length - 1; i++)
  79.             {
  80.                 Console.WriteLine(Biggest(a[i]) + Smallest(a[i+1]));
  81.             }
  82.         }
  83.     }
  84. }
  85.  
  86. //#3
  87. using System;
  88. using System.Collections.Generic;
  89. using System.Linq;
  90. using System.Text;
  91.  
  92. namespace ConsoleApplication2
  93. {
  94.     class Program
  95.     {
  96.         static void Kelet(int[] a)
  97.         {
  98.             for (int i = 0; i < a.Length; i++)
  99.                 a[i] = int.Parse(Console.ReadLine());
  100.         }
  101.         static bool Middle(int a, int b, int c)
  102.         {
  103.             return (b > a && b > c);
  104.         }
  105.         static void Main(string[] args)
  106.         {
  107.             int[] a = new int[10];
  108.             Kelet(a);
  109.             int counter = 0;
  110.             for (int i = 2; i < a.Length; i++)
  111.                 if (Middle(a[i - 2], a[i - 1], a[i]))
  112.                     counter++;
  113.             Console.WriteLine(counter);
  114.         }
  115.     }
  116. }
  117.  
  118. //#4
  119. using System;
  120. using System.Collections.Generic;
  121. using System.Linq;
  122. using System.Text;
  123.  
  124. namespace ConsoleApplication2
  125. {
  126.     class Program
  127.     {
  128.         static void Kelet(int[] a)
  129.         {
  130.             for (int i = 0; i < a.Length; i++)
  131.                 a[i] = int.Parse(Console.ReadLine());
  132.         }
  133.         static double Do(int[] a)
  134.         {
  135.             int n = a.Length;
  136.             if (n % 2 == 0)
  137.             {
  138.                 return (a[n / 2 - 1] + a[n / 2]) / 2;
  139.             }
  140.             else
  141.             {
  142.                 return a[n / 2];
  143.             }
  144.         }
  145.         static void Main(string[] args)
  146.         {
  147.             int n = int.Parse(Console.ReadLine());
  148.             int[] a = new int[n];
  149.             Kelet(a);
  150.             a[0] = (int)Do(a);
  151.         }
  152.     }
  153. }
  154.  
  155. //#5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement