Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static int countDigits(int n)
- {
- int c = 0;
- while (n != 0)
- {
- c++;
- n /= 10;
- }
- return c;
- }
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- Console.WriteLine("--------------------\n");
- if (n == 2)
- Q2();
- else if (n == 3)
- Q3();
- else if (n == 4)
- Q4();
- }
- static void Q2()
- {
- int max = 0, maxN = 0;
- for (int i = 1; i <= 10; i++)
- {
- int n = int.Parse(Console.ReadLine()), temp = n;
- while (n != 0)
- {
- if (n % 100 > max)
- {
- max = n % 100;
- maxN = temp;
- }
- n /= 10;
- }
- }
- Console.WriteLine(maxN);
- }
- static void Q3()
- {
- int a = int.Parse(Console.ReadLine());
- int b = int.Parse(Console.ReadLine());
- while (!(a == -1 && b == -1))
- {
- int c = countDigits(b);
- Console.WriteLine(a * Math.Pow(10, c) + b);
- a = int.Parse(Console.ReadLine());
- b = int.Parse(Console.ReadLine());
- }
- }
- static void Q4()
- {
- int a = int.Parse(Console.ReadLine());
- int b = int.Parse(Console.ReadLine());
- bool finalFlag = true;
- while (b != 0)
- {
- int tempA = a;
- bool digitFlag = false;
- while (tempA != 0)
- {
- if (b % 10 == tempA % 10)
- digitFlag = true;
- tempA /= 10;
- }
- if (!digitFlag)
- finalFlag = false;
- b /= 10;
- }
- Console.WriteLine(finalFlag);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement