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


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


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(Console.ReadLine()); double s = 1; void sum(int a,double b){ for(int i = 2; i <= a; i++){
b+=(Math.Pow(-1,i)*Math.Pow(i,-1)); } Console.WriteLine(b);} sum(k,s);
_______________________________________________________________________________________________________________________________
№2.Matnli faylda S satr berilgen. Satrdagi so`zlar sonini aniqlovchi sinf yarating.
sozlerSaniClass myObj = new sozlerSaniClass(); string f = File.ReadAllText("C:\\Users\\USER\\Desktop\\JAZIW.txt");
myObj.EkrangaShigariw(f); class sozlerSaniClass{ public void EkrangaShigariw(string gap){ string[] massiv = gap.Split(); Console.WriteLine(massiv.Length);} }
_______________________________________________________________________________________________________________________________
№3.A (A>1) butun soni berilgen. A sonini Tub songa tekshiruvchi TubSon(A, T) sinfi tuzilsin. Bu yerda T – mantiqiy túrdagi kiruvchi/chiquvchi parametr.
Console.Write("A="); int A = int.Parse(Console.ReadLine()); bool T = true; Tubson myObj = new Tubson(); myObj.EkrangaShigariw(A,T); class Tubson { public void EkrangaShigariw(int a,bool t){ int sum=0;
if(a!=2 && a%2==0||a==1) {t = false; Console.WriteLine(t);}else{for(int i=1;i<=a;i++){if(a%i==0) {sum++;} }
if(sum>2){t = false; Console.WriteLine(t);}else{Console.WriteLine(t); } } } }
_______________________________________________________________________________________________________________________________
№4.Matnli faylda satr berilgen. ushbu satrning ichida bosh harflar qatnashgan so`zlar sonini aniqlovchi sinf yarating.
sozlerSaniClass myObj = new sozlerSaniClass(); string f = File.ReadAllText("C:\\Users\\USER\\Desktop\\JAZIW.txt");
myObj.EkrangaShigariw(f); class sozlerSaniClass{ public void EkrangaShigariw(string gap){ int sum = 0; int sum2 = 0; string[] D = gap.Split(); for(int i = 0; i < D.Length; i++){for(int j = 0; j < D[i].Length; j++){
if (D[i][j] >= 'A' && D[i][j]<='Z'|| D[i][j] >='А'&& D[i][j]<='Я') {sum++;} } if(sum>0){sum2++; } sum=0; }
Console.WriteLine(sum2); } }
_______________________________________________________________________________________________________________________________

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