Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static string Question1(string a, string b)
- {
- string c = "";
- int length;
- if (a.Length > b.Length) length = a.Length;
- else length = b.Length;
- for (int i = 0; i < length; i++)
- {
- if (a.Length > i) c += a[i];
- if (b.Length > i) c += b[i];
- }
- return c;
- }
- static void Question2(int n)
- {
- for (int i = 1; i <= n; i++)
- if (i % 3 == 0 && i % 5 == 0) Console.WriteLine("FizzBuzz");
- else if (i % 3 == 0) Console.WriteLine("Fizz");
- else if (i % 5 == 0) Console.WriteLine("Buzz");
- else Console.WriteLine(i);
- }
- static int Question3(long n)
- {
- for (int i = 2; i < n / 2; i++)
- if (n % i == 0) return i;
- return 1;
- }
- static string Question4(string[] strings)
- {
- bool[] alphabet = new bool[26];
- bool correct = true;
- string panagram = "";
- for (int i = 0; i < strings.Length; i++)
- {
- for (int r = 0; r < alphabet.Length; r++) alphabet[r] = false;
- for (int j = 0; j < strings[i].Length; j++) if (strings[i][j] != ' ') alphabet[(int)strings[i][j] - 97] = true;
- for (int k = 0; k < alphabet.Length && correct == true; k++) if (alphabet[k] == false) correct = false;
- if (correct) panagram += "1";
- else panagram += "0";
- correct = true;
- }
- return panagram;
- }
- //Incomplete
- static int Question5()
- {
- double average;
- string initial = Console.ReadLine();
- var temp = "";
- int? n = null;
- int m = 0;
- int? a = null;
- int? b = null;
- int? k = null;
- for (int i = 0; i < initial.Length; i++)
- {
- if (initial[i] != ' ') temp += initial[i];
- else
- {
- if (n == null) n = Convert.ToInt32(temp);
- else m = Convert.ToInt32(temp);
- }
- }
- for (int i = 0; i < m; i++)
- {
- initial = Console.ReadLine();
- if (initial[i] != ' ') temp += initial[i];
- else
- {
- if (a == null) a = Convert.ToInt32(temp);
- else if (b == null) b = Convert.ToInt32(temp);
- else k = Convert.ToInt32(temp);
- initial = "";
- }
- }
- }
- static void Main(string[] args)
- {
- Console.WriteLine(Question1("abc", "defg"));
- Question2(15);
- Console.WriteLine(Question3(21));
- string[] question4 = new string[] {"we promptly judged antique ivory buckles for the next prize",
- "we promptly judged antique ivory buckles for the prizes",
- "the quick brown fox jumps over the lazy dog",
- "the quick brown fox jump over the lazy dog" };
- Console.WriteLine(Question4(question4));
- Console.ReadLine();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement