№29. Matnli faylda S satri berilgan. Berilgan satrda o'ng sonlar sonin aniqlovchi dastur tuzilsin.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
using System.IO; namespace ConsoleApplication1{class Program{ static void Main(string[] args){
StreamReader uqish = new StreamReader("g:\\uqish.txt");string s = uqish.ReadLine();string[] s1 = s.Split('-');
string[] s2 = s.Split(' ');if (s2.Length + s1.Length > 0) Console.WriteLine(s2.Length + 1 - s1.Length);
else Console.WriteLine(1);uqish.Close();Console.ReadKey();}}}
_______________________________________________________________________________________________________________________________
№30. Matnli faylda S satri berilgan. Berilgan satrda teskari sonlar sonin aniqlovchi sinf yarating.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
using System.IO; namespace ConsoleApplication1{class Program{ static void Main(string[] args){
StreamReader uqish = new StreamReader("g:\\uqish.txt");string s = uqish.ReadLine(); string[] s1 = s.Split(',');
if (s1.Length > 0) Console.WriteLine(s1.Length - 1); else Console.WriteLine(0);uqish.Close(); Console.ReadKey();} } }
_______________________________________________________________________________________________________________________________
№31. Matnli faylda S satri berilgan. Qatordagi so'zlar sonin toping (har bitta so'z bitta probel bilan ajratilgan ).
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
using System.IO; namespace ConsoleApplication1{class Program{ static void Main(string[] args){
StreamReader uqish = new StreamReader("g:\\uqish.txt");string s = uqish.ReadLine();string[] s1 = s.Split(' ');
Console.WriteLine(Math.Abs(s1.Length-1));uqish.Close();Console.ReadKey();} } }
_______________________________________________________________________________________________________________________________
№
Do'stlaringiz bilan baham: |