Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Exam01
- {
- class Program
- {
- public static int mult(int m, int n)
- {
- if (n == 1)
- {
- return m;
- }
- return mult(m, n - 1) + m;
- }
- public static int mult2(int m, int n)
- {
- if (n == 1)
- {
- return m;
- }
- else if (n > 1)
- {
- return mult2(m, n - 1) + m;
- }
- return mult2(m, n + 1) - m;
- }
- static void Main(string[] args)
- {
- // Exam 01:
- /*int days = int.Parse(Console.ReadLine());
- int[] cards = { 100, 20 };
- int money = days * 20;
- int count = 0;
- for (int i = 0; i < cards.Length; i++)
- {
- while (money - cards[i] >= 0)
- {
- money -= cards[i];
- count++;
- }
- if (money == 0)
- {
- break;
- }
- }
- Console.WriteLine(count);*/
- // Exam02:
- int[] numbers = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
- int result = mult2(numbers[0], numbers[1]);
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement