1. k (K>1) butun soni berilgen. S=1+1/2-1/3+1/4-…+(-1) K*1/K yig`indini hisoblovchi Sum(K,S) funksiyasini tuzing. Bu yerda s – kiuvchi/chiquvchi parametr. Console. Write("k="); int k = int. Parse


№29. Matnli faylda S satri berilgan. Berilgan satrda o'ng sonlar sonin aniqlovchi dastur tuzilsin


Download 23.83 Kb.
bet3/4
Sana04.02.2023
Hajmi23.83 Kb.
#1158636
1   2   3   4
Bog'liq
algoritim

№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();} } }
_______________________________________________________________________________________________________________________________

Download 23.83 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling