Masalaning C# dasturlash tilidagi matni


Download 1.79 Mb.
bet2/2
Sana19.06.2023
Hajmi1.79 Mb.
#1608778
1   2
Bog'liq
topshiriq 19

Masalaning C# dasturlash tilidagi matni:

using System;


using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication15


{
class Program
{
static void Malumot(out double a, out double b, out double c)
{
Console.WriteLine("Uchburchak tomonlarini kiriting");
Console.Write("1 - tomonlarini kiriting: a= ");
a = Convert.ToDouble(Console.ReadLine());
Console.Write("2 - tomonlarini kiriting: b= ");
b = Convert.ToDouble(Console.ReadLine());
Console.Write("3 - tomonlarini kiriting c= ");
c = Convert.ToDouble(Console.ReadLine());
}
static void Bissektrisa(double a, double b, double c, out double La, out double Lb, out double Lc)
{
double p = (a + b + c) / 2;
La = 2 * Math.Sqrt(c * b * (p * (p - a))) / (c + b);
Lb = 2 * Math.Sqrt(a * c * (p * (p - a))) / (a + c);
Lc = 2 * Math.Sqrt(a * b * (p * (p - c))) / (a + b);
}
public static void Main(string[] args)
{
double a, b, c, La, Lb, Lc;
Malumot(out a, out b, out c);
Bissektrisa(a, b, c, out La, out Lb, out Lc);
Console.WriteLine("1-bissektrisa: " + La);
Console.WriteLine("2-bissektrisa: " + Lb);
Console.WriteLine("3-bissektrisa: " + Lc);
Console.ReadKey(true);
}
}
}



6. Bosh harflar bilan kiritilgan va bitta yoki bir nechta probel bilan ajratilgan
ruscha so’zlardan tuzilgan S satr berilgan. Uchta “A” harfi bo’lgan so’zlar
sonini topish dasturi tuzilsin.
Masalaning C# dasturlash tilidagi matni:

using System;


using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication19


{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Matn kiriting: ");
string text = Console.ReadLine();
string[] sozlar = text.Split();
int count = 0;
foreach (string soz in sozlar)
{
if (soz.Count(s => s == 'A') > 2)
{
count++;
}
}
Console.WriteLine("Natija: {0} ta ",count);
Console.ReadKey(true);


}
}
}
Download 1.79 Mb.

Do'stlaringiz bilan baham:
1   2




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