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 HelloWorld1b
- {
- class Program
- {
- static void Main(string[] args)
- {
- int age = 50;
- decimal money = 2.544234342342342342342342342342423M;
- char firstLetter = 'S'; // '\u0fff';
- bool isMail = true;
- int nextYear = (age + 1) * 8;
- bool result = 1 + 4 * 5 > 34 % 5 + 5 - 6 && 21321 % 4 - 6 <= 32423 % 6 + 4;
- string name = "Stoyan";
- object myObject = 5;
- Console.WriteLine("Hello World! And my age: " + age);
- Console.WriteLine("I have : " + money);
- Console.WriteLine("The first letter of my name is : " + firstLetter);
- Console.WriteLine(isMail);
- Console.WriteLine(name);
- Console.WriteLine(nextYear);
- Console.WriteLine(result);
- Console.WriteLine("Please enter your age:");
- string age1 = Console.ReadLine();
- Console.WriteLine("{1}You have entered: {0} ", age1, age);
- int ageConverted = int.Parse(age1);
- if (ageConverted < 20)
- {
- Console.WriteLine("You are an teenager");
- }
- else if (ageConverted >= 20 && ageConverted < 30)
- {
- Console.WriteLine("You are in your twentees");
- }
- else {
- Console.WriteLine("I don't know what to say");
- }
- switch (ageConverted) {
- case 10:
- case 20:
- Console.WriteLine("perfect age");
- break;
- case 30:
- Console.WriteLine("Very nice");
- break;
- default :
- Console.WriteLine("You are not 20 or 30 years old. I don't know.");
- break;
- }
- Console.WriteLine(1);
- Console.WriteLine(2);
- Console.WriteLine(3);
- // ...
- int i = 1;
- while ( i <= 10) {
- if (i == 5) break;
- Console.WriteLine("while: {0}: ", i);
- i++;
- }
- Console.WriteLine("Please select [1-4]:");
- Console.WriteLine("1. List partitions");
- Console.WriteLine("2. Create a partiono");
- Console.WriteLine("3. Delete partition");
- Console.WriteLine("4. Exit");
- string choice = "";
- while (true) {
- choice = Console.ReadLine();
- // ... do somethign smart
- // if (choice == "4") {
- if (int.Parse(choice) == 4)
- {
- break;
- }
- }
- i = 11;
- do {
- Console.WriteLine("do-while: {0}", i);
- i++;
- } while(i <= 10);
- for (i = 0; i < 10; i++) {
- if (i % 2 != 1) continue;
- Console.WriteLine("for {0}", i);
- }
- string[] group1b = { "Georgi", "Ivan", "Georgi", "Dimitar", "Daniel", "Maria", "Angel", "Stefan", "Dean"};
- foreach (string namestr in group1b) {
- Console.WriteLine(namestr);
- }
- for (i = 0; i < 10; i++) {
- for (int j = 0; j < i; j++) {
- Console.Write("*");
- }
- Console.WriteLine();
- }
- /*
- int[] myArray;
- myArray = new int[5];
- myArray[4] = 45;
- */
- // 2)
- // int[] myArray = { 32, 45, 67, 890 };
- int[] myArray = new int[3] { 23, 45, 46 };
- for (i = 0; i < myArray.Length; i++) {
- Console.WriteLine("myArray[{0}] = {1}", i, myArray[i]);
- }
- string[,] positionsOfTheStudents = {
- {"Hristo", "Georgi","","","Ivan","", "","Georgi"},
- {"Dimitar", "Daniel","","Maria","","", "","Angel"},
- {"Stefan", "","","Dean","","", "",""}
- };
- for (i = 0; i < positionsOfTheStudents.GetLength(0); i++)
- {
- Console.Write("Red {0}: ", i);
- for (int j = 0; j < positionsOfTheStudents.GetLength(1); j++)
- {
- Console.Write(" {0}", positionsOfTheStudents[i, j]);
- }
- Console.WriteLine();
- }
- int[][] jaggedArray;
- jaggedArray = new int[2][];
- jaggedArray[0] = new int[8];
- jaggedArray[1] = new int[5];
- /*
- string temp = "";
- for (i = 0; i < 15; i++) {
- temp += "*";
- }
- Console.WriteLine(temp);
- temp = "";
- for (i = 0; i < 5; i++)
- {
- temp += "@";
- }
- Console.WriteLine(temp);
- */
- Console.WriteLine(createString(12));
- Console.WriteLine(createString(10));
- Console.WriteLine(createString(5));
- Console.WriteLine(createString(15, "@"));
- Console.WriteLine(createString(15, "@", "Stoyan", "Ivan", "blah blah"));
- Console.WriteLine(createString());
- Console.WriteLine("Factorial from {0} = {1}", 6, factorial(6));
- Console.WriteLine("Factorial from {0} = {1}", 6, factorialIteration(6));
- for (i = 0; i < 10; i++)
- {
- Console.WriteLine("Fibonacci {0} => {1}", i, fibonacci(i));
- }
- }
- static string createString(int strLength, string str = "*", params string[] par)
- {
- string temp = "";
- for (int i = 0; i < strLength; i++)
- {
- temp += str;
- }
- foreach (string name in par) {
- Console.WriteLine(name);
- }
- return temp;
- }
- static string createString() {
- return "Hahahaha";
- }
- /*
- static string createString(int sadh, string erwrew = "*", params string[] par)
- {
- return "Error!!!";
- }
- */
- static int factorial(int n) {
- if (n == 0) return 1;
- return factorial(n - 1) * n;
- }
- static int factorialIteration(int n)
- {
- var factorial = 1;
- for (int i = 1; i <= n; i++)
- {
- factorial *= i;
- }
- return factorial;
- }
- static int fibonacci(int n) {
- if (n <= 2) return 1;
- return fibonacci(n - 2) + fibonacci(n - 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement