Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- namespace Practice
- {
- class App
- {
- static void Main(string[] args)
- {
- }
- static void Exercise26NumReversor()
- {
- int num = int.Parse(Console.ReadLine());
- int reversedNum = 0;
- int numForCalcs = num;
- int i = 1;
- while (numForCalcs != 0)
- {
- numForCalcs /= 10;
- i *= 10;
- }
- while (num != 0)
- {
- i /= 10;
- reversedNum += num % (10) * i;
- num /= 10;
- }
- Console.WriteLine(reversedNum);
- }
- static void Exercise23BiggestCouple()
- {
- int count = 0, biggestSum, num1, num2;
- num1 = int.Parse(Console.ReadLine());
- num2 = int.Parse(Console.ReadLine());
- biggestSum = num1 + num2;
- while ((num1 % 2 == 0 && num2 % 2 == 0) || (num1 % 2 != 0 && num2 % 2 != 0))
- {
- num1 = int.Parse(Console.ReadLine());
- num2 = int.Parse(Console.ReadLine());
- if ((num1 + num2) > biggestSum)
- biggestSum = num1 + num2;
- count++;
- }
- Console.WriteLine("Count: {0}\nBiggest sum: {1}", count, biggestSum);
- }
- static void Exercise24TomNJerry()
- {
- int tom = 10, jerry = 40, move, count = 0;
- bool gameOver = false, playerIsTom = false;
- string player = "Jerry";
- Random rnd = new Random();
- while (!gameOver)
- {
- count++;
- playerIsTom = !playerIsTom;
- if (playerIsTom)
- {
- player = "Tom";
- move = rnd.Next(-5, 6);
- tom += move;
- }
- else
- {
- player = "Jerry";
- move = rnd.Next(-5, 6);
- jerry += move;
- }
- Console.WriteLine("Tom: {0}\nJerry: {1}\nLength: {2}\n", tom, jerry, count);
- if (tom > 50 || jerry > 50 || tom < 0 || jerry < 0)
- {
- Console.WriteLine("{0} lost the game!\n", player);
- gameOver = true;
- }
- if (tom == jerry)
- {
- Console.WriteLine("{0} won the game!\n", player);
- gameOver = true;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement