Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#1
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- static void Main(string[] args)
- {
- string st = Console.ReadLine();
- int k = st.Length - 2;
- Console.WriteLine(st.Substring(0, 1));
- Console.WriteLine(st.Substring(st.Length - 1));
- Console.WriteLine(st.Substring(st.Length / 2, 1));
- Console.WriteLine(st.Substring(0, st.Length / 2));
- Console.WriteLine(st.Substring(st.Length/2));
- Console.WriteLine(st.Substring(0, 3));
- Console.WriteLine(st.Substring(st.Length - 3));
- Console.WriteLine(st.Substring(0, k));
- Console.WriteLine(st.Substring(st.Length - k));
- st.Replace("go", "went");
- }
- }
- }
- //#2
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- static void Main(string[] args)
- {
- string ktovet = Console.ReadLine();
- string city = Console.ReadLine();
- int index = ktovet.IndexOf(city);
- if (index >= 0)
- ktovet = ktovet.Remove(index, city.Length);
- Console.WriteLine(ktovet);
- }
- }
- }
- //#3
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- static void Main(string[] args)
- {
- string st = "aal aiv isn't kam";
- int i = 2, counter = 0;
- if (st[0] == 'a')
- counter++;
- while (i < st.Length)
- {
- if (st[i] == 'a' && st[i-1] == ' ')
- counter++;
- i++;
- }
- Console.WriteLine(counter);
- }
- }
- }
- //#4
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- static void Main(string[] args)
- {
- string st = "aaa aia isn'a kaa";
- int i = 2, counter = 0;
- if (st[st.Length - 1] == 'a')
- counter++;
- while (i < st.Length - 2)
- {
- if (st[i] == 'a' && st[i+1] == ' ')
- counter++;
- i++;
- }
- Console.WriteLine(counter);
- }
- }
- }
- //#5
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- static void Main(string[] args)
- {
- string st = "aaY aia isn'Y kaa";
- int i = 2, counter = 0;
- if (st[st.Length - 1] == 'Y')
- counter++;
- while (i < st.Length - 2)
- {
- if (st[i] == 'Y' && st[i+1] == ' ')
- counter++;
- i++;
- }
- Console.WriteLine(counter);
- }
- }
- }
- //#6
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- static void Main(string[] args)
- {
- string st = "galnivmagniv", x = Console.ReadLine();
- int mone = 0;
- while (st.IndexOf(x) > 0)
- {
- mone++;
- st = st.Remove(st.IndexOf(x), x.Length);
- }
- Console.WriteLine(mone);
- }
- }
- }
- //#7
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- static void Main(string[] args)
- {
- string st = "galnivmagniv", x = Console.ReadLine(), y = Console.ReadLine();
- int index = st.IndexOf(x);
- st = st.Insert(index, y);
- index += y.Length;
- st = st.Remove(index, x.Length);
- Console.WriteLine(st);
- }
- }
- }
- //#8
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] arr = { "gal", "liv", "magniv", "meod", "photography" };
- int mone = 0;
- for (int i = 0; i < arr.Length - 1; i++)
- {
- string last = arr[i], first=arr[i+1];
- last = last.Substring(last.Length - 1, 1);
- first = first.Substring(0, 1);
- if (last == first)
- mone++;
- }
- Console.WriteLine(mone);
- }
- }
- }
- //#9
- Go to this link the table is there - http://i.snag.gy/5S5Qu.jpg
- //#10
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- static void Main(string[] args)
- {
- string st = "galnivmagniv@photography.com";
- int index = st.IndexOf("@");
- if (index < 0)
- Console.WriteLine("Doesn't exist");
- else
- {
- st = st.Remove(index);
- Console.WriteLine(st);
- }
- }
- }
- }
- //#11
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- //א
- static string Sod0(string st)
- {
- string hafuh = "";
- for (int i = 0; i < st.Length; i++)
- {
- hafuh += st[st.Length - i - 1];
- }
- return hafuh;
- }
- //ב
- static bool Sod1(string st)
- {
- return st.Equals(Sod0(st));
- }
- static void Main(string[] args)
- {
- string st = Console.ReadLine();
- int i = 0;
- while (st != "exit")
- {
- if (!Sod1(st))
- Console.WriteLine(Sod0(st));
- else
- i++;
- st = Console.ReadLine();
- }
- Console.WriteLine(i);
- }
- }
- }
- //#12
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1524
- {
- class Program
- {
- static bool Hukit(string pass)
- {
- if (pass.Length != 6)
- return false;
- int mone = 0;
- for (int i = 0; i < pass.Length; i++)
- if (Char.IsLetter(pass[i]))
- mone++;
- if (mone < 3)
- return false;
- return true;
- }
- static void Main(string[] args)
- {
- string st = Console.ReadLine();
- if (Hukit(st))
- Console.WriteLine("WELLCOME");
- else
- {
- while (!Hukit(st))
- {
- Console.WriteLine("ERROR, INSERT ANOTHER PASSWORD");
- st = Console.ReadLine();
- }
- Console.WriteLine("WELLCOME");
- }
- }
- }
- }
- //#13
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication2
- {
- class Program
- {
- static string Spaces(string st)
- {
- while (st.IndexOf(" ") != -1)
- {
- st = st.Replace(" ", " ");
- }
- return st;
- }
- static void Main(string[] args)
- {
- Console.WriteLine(Spaces("a a a a a a a a a"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement