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 HelloWorld3a
- {
- class Program
- {
- static void Main(string[] args)
- {
- /*
- Console.WriteLine("Hello world аояьяоао!");
- Console.Beep(500, 1000);
- byte age = 53;
- decimal money;
- char firstLetter = 'S';
- string name = "Stoyan";
- bool isMale = true;
- money = 2.54m;
- firstLetter = 'T';
- Console.WriteLine("I am {0} years old.", age);
- Console.WriteLine("I have {0} money!", money);
- Console.WriteLine("I am {1} years old!. The first letter of my name is {0}. ", firstLetter, age);
- Console.WriteLine("My name is {0}", name);
- Console.WriteLine("Am I a man?{0}", isMale);
- byte a = 13;
- byte b = 5;
- // 1.
- Console.WriteLine("{0} + {1} = {2}",a, b, a + b);
- Console.WriteLine("{0} - {1} = {2}", a, b, a - b);
- Console.WriteLine("{0} * {1} = {2}", a, b, a * b);
- Console.WriteLine("{0} / {1} = {2}", a, b, a / b);
- Console.WriteLine("{0} % {1} = {2}", a, b, a % b);
- Console.WriteLine("++{0} = {1}", a, ++a);
- // 2. comparison
- Console.WriteLine("{0} < {1} = {2}", a, b, a < b);
- Console.WriteLine("{0} > {1} = {2}", a, b, a > b);
- Console.WriteLine("{0} <= {1} = {2}", a, b, a <= b);
- Console.WriteLine("{0} >= {1} = {2}", a, b, a >= b);
- Console.WriteLine("{0} == {1} = {2}", a, b, a == b);
- Console.WriteLine("{0} == {1} = {2}", a, b, a != b);
- // 3. Boolean
- bool c = true;
- bool d = false;
- Console.WriteLine("{0} && {1} = {2}", c, d, c && d);
- Console.WriteLine("{0} || {1} = {2}", c, d, c || d);
- Console.WriteLine("{0} ^ {1} = {2}", c, d, c ^ d);
- Console.WriteLine("!{0} = {1}", c, !c);
- // kdjsfhsdkfjh askjfsdk fdkjh fksjh fkjsd
- // a = 5; // a = a + 5;
- Console.WriteLine("{0} << 1 {1}", 1, 1 << 1);
- Console.WriteLine("{0} >> 1 {1}", 1, 1 >> 1);
- Console.WriteLine("{0} | {1} = {2}", a, b, a | b);
- Console.WriteLine("{0} & {1} = {2}", a, b, a & b);
- Console.WriteLine("{0} ^ {1} = {2}", a, b, a ^ b);
- Console.WriteLine("~{0} = {1}", a, ~a);
- Console.WriteLine("Please, enter your age:");
- string input = Console.ReadLine();
- byte newAge = byte.Parse(input);
- Console.WriteLine("In 10 years you will be {0}", input + 10);
- if( newAge <= 18 )
- {
- Console.WriteLine("You are a teenager!!!");
- }
- else if (newAge > 18 && newAge <= 30)
- {
- Console.WriteLine("You are in a golden age!");
- }
- else
- {
- Console.WriteLine("You are an adult!");
- }
- switch (newAge)
- {
- case 22 :
- case 23 :
- Console.WriteLine("You are 23 years old. You are very sick person!");
- break;
- default :
- Console.WriteLine("I don't know what to say!");
- break;
- }
- */
- //Console.WriteLine(1);
- //Console.WriteLine(2);
- //Console.WriteLine(3);
- int i = 1;
- while (i <= 10)
- {
- if (i == 5) break;
- Console.WriteLine(i);
- i++;
- }
- i = 11;
- do
- {
- Console.WriteLine("do-while: {0}", i);
- i++;
- } while (i <= 10);
- /*
- string choice = "0";
- do
- {
- Console.Clear();
- Console.WriteLine("Моля изберете номер на рецепта:");
- Console.WriteLine("1. Пържени яйца");
- Console.WriteLine("2. Пиле с ориз");
- Console.WriteLine("3. фасул");
- Console.WriteLine("4. Изход от програмата");
- choice = Console.ReadLine();
- if (choice == "4") break;
- if (choice == "1")
- {
- Console.Clear();
- Console.WriteLine("За да се върнеш в основното меню натисни кой да е клавиш и после Enter");
- Console.WriteLine("За да си опържеш яйца...");
- Console.ReadLine();
- }
- }while(true);
- */
- for (i = 0; i < 10; i++)
- {
- if (i % 2 != 0) continue;
- // if (i % 2 == 0)
- //{
- Console.WriteLine("for even {0}", i);
- //}
- }
- string[] studentNames = { "Robeta", "Mirela", "Nikola",
- "Adrian", "Mitko", "Milen", "Sabrin",
- "Valentin", "Ivan", "Stafan", "Nora",
- "Dani", "Konstantin", "Silvestar", "Mirela"};
- foreach (string name in studentNames)
- {
- Console.WriteLine(name);
- }
- int[] myArray;
- myArray = new int[5];
- myArray[4] = 45;
- // 2.
- // int[] myArray = new int[5];
- // 3.
- // int[] myArray = {0, 0, 0, 0, 45}
- for (i = 0; i < myArray.Length; i++)
- {
- Console.WriteLine("myArray[{0}] = {1}", i, myArray[i]);
- }
- //string[,] positionsOfTheStudents;
- //positionsOfTheStudents = new string[3, 8];
- //positionsOfTheStudents[0, 0] = "Roberta";
- string[,] positionsOfTheStudents = {
- {"Roberta", "Mirela","Nikola","","","Adrian", "","Mitko"},
- {"Milen", "Sabrin","","","Ivan","", "","Stafan"},
- {"Nora", "Dani","","Konstantin","Silvestar","", "","Mirela"}
- };
- for (i = 0; i < positionsOfTheStudents.GetLength(0); i++)
- {
- for (int j = 0; j < positionsOfTheStudents.GetLength(1); j++)
- {
- Console.WriteLine("positionsOfTheStudents[{0},{1}] = {2}", i, j, positionsOfTheStudents[i,j]);
- }
- }
- int[][] jaggedArray;
- jaggedArray = new int[2][];
- jaggedArray[0] = new int[8];
- jaggedArray[1] = new int[5];
- byte result = 148;
- Console.WriteLine(Convert.ToString(result, 2).PadLeft(16, '0'));
- /*
- for (i = 0; i < 10; i++)
- {
- Console.Write('*');
- }
- Console.WriteLine();
- for (i = 0; i < 20; i++)
- {
- Console.Write('^');
- }
- */
- Console.WriteLine(createString(20));
- Console.WriteLine(createString(10, '^'));
- Console.WriteLine("factorial(3) = {0}", factorial(3));
- Console.WriteLine("factorial(3) = {0}", factorialIteration(3));
- }
- static string createString(int n, char c = '*')
- {
- string temp = "";
- for (int i = 0; i < n; i++)
- {
- temp += c;
- }
- return temp;
- }
- static int factorial(int n)
- {
- if (n == 0) return 1;
- return factorial(n - 1) * n;
- }
- static int factorialIteration(int n)
- {
- if (n == 0) return 1;
- int temp = 1;
- for (int i = 1; i <= n; i++)
- {
- temp *= i; // temp = temp * i;
- }
- return temp;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement