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;
- using System.Threading.Tasks;
- namespace BangbuttExc
- {
- class Program
- {
- //Question 2
- public static int[] BigArr(int[,] a)
- {
- int[] b = new int[5];
- int sum, count = 0;
- for (int i = 0; i < a.GetLength(0); i++)
- {
- sum = 0;
- for (int k = 0; k < a.GetLength(1); k++)
- sum += a[i, k];
- if (sum > 100)
- {
- b[count] = i;
- count++;
- }
- }
- return b;
- }
- //Question 3
- public static void SolveQ2()
- {
- int num, count = 0;
- for(int i = 1; i < 26; i++)
- {
- num = int.Parse(Console.ReadLine());
- if (Math.Abs(num - i) <= 2)
- count++;
- }
- Console.WriteLine(count);
- }
- //Question 5
- public static bool ContainsChars(string st1, string st2)
- {
- bool flag;
- for (int i = 0; i < st1.Length; i++)
- {
- flag = false;
- for (int m = 0; m < st2.Length; m++)
- if (st2[m] == st1[i])
- flag = true;
- if (!flag)
- return false;
- }
- return true;
- }
- //Question 7a
- public static char CharStuff(string st1, string st2)
- {
- if (st1.Length > st2.Length)
- {
- if (st1.Length == 2 * st2.Length)
- return st2[st2.Length - 1];
- return st1[st1.Length - 1];
- }
- else
- {
- if(st2.Length == 2 * st1.Length)
- return st1[st1.Length - 1];
- return st2[st2.Length - 1];
- }
- }
- //Question 7b
- public static void SolveQ7()
- {
- string output = "", st1, st2;
- for (int i = 0; i < 4; i++)
- {
- st1 = Console.ReadLine();
- st2 = Console.ReadLine();
- output += CharStuff(st1, st2);
- }
- Console.WriteLine(output);
- }
- //Question 8a
- public static int GetMonth(string st)
- {
- return int.Parse(st.Substring(3, 2));
- }
- //Question 8b
- public static void SolveQ8()
- {
- int count1 = 0, count2 = 0, count3 = 0, count4 = 0;
- string st;
- st = Console.ReadLine();
- while (st != "00/00/0000")
- {
- switch (GetMonth(st))
- {
- case 9:
- case 10:
- case 11:
- count1++;
- break;
- case 12:
- case 1:
- case 2:
- count2++;
- break;
- case 3:
- case 4:
- case 5:
- count3++;
- break;
- default:
- count4++;
- break;
- }
- Console.WriteLine(GetMonth(st));
- st = Console.ReadLine();
- }
- Console.WriteLine("Fall - " + count1);
- Console.WriteLine("Winter - " + count2);
- Console.WriteLine("Spring - " + count3);
- Console.WriteLine("Summer(time sadness) - " + count4);
- }
- //Question 9a
- public static bool DominantCell(int[,] arr, int a, int b)
- {
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- if (arr[i, b] >= arr[a, b])
- return false;
- }
- for (int i = 0; i < arr.GetLength(1); i++)
- {
- if (arr[a, i] >= arr[a, b])
- return false;
- }
- return true;
- }
- //Question 9b
- public static bool DominantDiagonal(int[,] arr)
- {
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- if (!DominantCell(arr, i, i))
- return false;
- }
- return true;
- }
- //Question 10a
- public static void InitializeArray(int[,] arr)
- {
- int input;
- input = int.Parse(Console.ReadLine());
- while (input != 999)
- {
- arr[input / 100 - 1, (input / 10) % 10 - 1] = input % 10;
- input = int.Parse(Console.ReadLine());
- }
- }
- //Question 10b
- public static int FrameSum(int[,] arr)
- {
- int sum = 0;
- for (int k = 0; k < arr.GetLength(1); k += arr.GetLength(1) - 1)
- {
- for (int i = 0; i < arr.GetLength(0); i++)
- sum += arr[i, k];
- }
- for (int k = 0; k < arr.GetLength(0); k += arr.GetLength(0) - 1)
- {
- for (int i = 1; i < arr.GetLength(1) - 1; i++)
- sum += arr[k, i];
- }
- return sum;
- }
- //Question 10c(kinda)
- public static bool LegitAndShit(int[,] arr)
- {
- int sum = 0;
- for(int i = 0; i < arr.GetLength(0); i++)
- for(int k = 0; k < arr.GetLength(1); k++)
- sum += arr[i, k];
- return FrameSum(arr) > sum / 2;
- }
- static void Main(string[] args)
- {
- SolveQ2();
- SolveQ8();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement