kisame1313

1.3.6.2

Jul 18th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2. /*
  3.  * С помощью params сделать возможным передачу любого количества цифр в метод.
  4.  * В самом методе умножить все принятые цифры и вернуть их произведение.
  5.  * P.S Эта задача решается только с помощью циклов.
  6.  */
  7. namespace ConsoleApplication
  8. {
  9.     class Program
  10.     {
  11.         static void Main ( string [] args )
  12.         {
  13.             Console.WriteLine ( SomeMul(0) );
  14.         }
  15.  
  16.         static int SomeMul ( params  int [] arr)
  17.         {
  18.             int answ = arr [0];
  19.             for ( int i = 0 ; i < arr.Length-1 ; i++ )
  20.             {
  21.                 answ  *= arr [i + 1];
  22.             }
  23.             return answ;
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment