Advertisement
VEGASo

(C#) Lab #3 Ex. 1 (Вариант 7)

Oct 15th, 2022
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2.  
  3. namespace LearnRSUE
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int one, two, AllNumb = 0, Sum = 0;
  10.  
  11.             Console.Write("От какого числа(диапазон): ");
  12.             one = Convert.ToInt32(Console.ReadLine());
  13.  
  14.             Console.Write("До какого числа(диапазон): ");
  15.             two = Convert.ToInt32(Console.ReadLine());
  16.  
  17.  
  18.             for (int i = one; i <= two; i++)
  19.             {
  20.                 if (i % 10 == 7 || (i % 100) % 10 == 7)
  21.                 {
  22.                     Console.WriteLine(i);
  23.  
  24.                     AllNumb++;
  25.                     Sum += i;
  26.                 }
  27.             }
  28.  
  29.             Console.WriteLine("\nКоличество чисел - " + AllNumb);
  30.             Console.WriteLine("Сумма чисел - " + Sum);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement