Using System. Io; namespace File 1 { class Program { public


Dasturning C# dagi ko’rinishi



Download 64,29 Kb.
bet3/6
Sana03.04.2022
Hajmi64,29 Kb.
#526700
1   2   3   4   5   6
Bog'liq
File 1

Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_15
{
class Program
{
public static void Main(string[] args)
{
string s;char [] m={' ',','};double c=0;int n=0;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
string [] h=File.ReadAllLines(@"d:\"+s);
for (int i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
for (int j=n;j{
c+=Convert.ToInt32(a[j]);
}
if (a.Length%2==1) n=1;
else n=0;
}
Console.WriteLine("Natija: "+c);
Console.ReadKey(true);
}
}
}

Natija:
File 16. Butun sonlar fayli berilgan. Undagi seriyalar sonini topish dasturi tuzilsin. Masalan, 1, 5, 5, 5, 4, 4, 5 elementli fayl uchun natija 4 ga teng.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_16
{
class Program
{
public static void Main(string[] args)
{
string s;char [] m={' ',','};double c=0,e;int n=1;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
string [] h=File.ReadAllLines(@"d:\"+s);
for (int i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
e=Convert.ToInt32(a[0]);if (i!=0& c!=e)n++;
for (int j=1;j{
c=Convert.ToInt32(a[j]);e=Convert.ToInt32(a[j-1]);
if (c!=e) n++;
}
}
Console.WriteLine("Natija: "+n);
Console.ReadKey(true);
}
}
}
Natija:
File 17. Butun sonlar fayli berilgan. Dastlabki faylning hamma seriyalari uzunligini o’zida aks ettiruvchi yangi fayl hosil qilinsin. Masalan, 1, 5, 5, 5, 4, 4, 5 elementli fayl uchun natijaviy fayl quyidagicha bo’lishi kerak: 1, 3, 2, 1
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_17
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',','};int n=1,c=0,e;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
Console.Write("Yaratiladigan fayl nomini kiriting: ");
s1=Console.ReadLine();
string [] h=File.ReadAllLines(@"d:\"+s);
for (int i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
e=Convert.ToInt32(a[0]);if (i!=0& c!=e) {File.AppendAllText(@"d:\"+s1,n.ToString()+" ");n=1;}
if (i!=0&c==e) n++;
for (int j=1;j{
c=Convert.ToInt32(a[j]);e=Convert.ToInt32(a[j-1]);
if (c!=e) {File.AppendAllText(@"d:\"+s1,n.ToString()+" ");n=1;}
else {n++;if (i==h.Length-1&j==a.Length-1)File.AppendAllText(@"d:\"+s1,n.ToString());}
}
}
Console.ReadKey(true);
}
}
}
Natija:
File 18. Haqiqiy sonlar fayli berilgan. Uning birinchi lokal minimum elementini topish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_18
{
class Program
{
public static void Main(string[] args)
{
string s;char [] m={' ',','};double d,b,c=0;
bool f=false;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();int i,j;
string [] h=File.ReadAllLines(@"d:\"+s);
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
for (j=1;j{
b=Convert.ToInt32(a[j-1]);c=Convert.ToInt32(a[j]);
d=Convert.ToInt32(a[j+1]);
if (cc) {f=true;break;}
}
if (f)break;
}
if (f)Console.WriteLine(c);
Console.ReadKey(true);
}
}
}
Natija:
File 19. Haqiqiy sonlar fayli berilgan. Uning oxirgi lokal maksimum elementini topish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_19
{
class Program
{
public static void Main(string[] args)
{
string s;char [] m={' ',','};double d,b,c=0,max=0;
bool f=false;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();int i,j;
string [] h=File.ReadAllLines(@"d:\"+s);
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
for (j=1;j{
b=Convert.ToDouble(a[j-1]);c=Convert.ToDouble(a[j]);
d=Convert.ToDouble(a[j+1]);
if (c>b&dtrue;max=c;}
}
}
if (f)Console.WriteLine(max);
Console.ReadKey(true);
}
}
}
Natija:
File 20. Haqiqiy sonlar fayli berilgan. Uning lokal ekstremumlari ya’ni lokal minimum va lokal maksimumlari sonini topish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_20
{
class Program
{
public static void Main(string[] args)
{
string s;char [] m={' ',','};double d,b,c;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();int i,j,n=0;
string [] h=File.ReadAllLines(@"d:\"+s);
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
for (j=1;j{
b=Convert.ToDouble(a[j-1]);c=Convert.ToDouble(a[j]);
d=Convert.ToDouble(a[j+1]);
if ((c>b&dc))n++;
}
}
Console.WriteLine(n);
Console.ReadKey(true);
}
}
}
Natija:
File 21. Haqiqiy sonlar fayli berilgan. Dastlabki faylning barcha lokal maksimumlari nomerini o’sish tartibida o’zida aks ettiruvchi yangi butun fayl hosil qilinsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_21
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',','};double d=0,b,c=0;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();int i,j,n=0;
Console.Write("Yaratiladigan fayl nomini kiriting: ");
s1=Console.ReadLine();
string [] h=File.ReadAllLines(@"d:\"+s);
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
b=Convert.ToDouble(a[0]);
if (i!=0) 
{
if (cb)File.AppendAllText(@"d:\"+s1,(n-1).ToString()+" ");
c=Convert.ToDouble(a[1]);
if (cAppendAllText(@"d:\"+s1,(n).ToString()+" ");
}
for (j=1;j{
b=Convert.ToDouble(a[j-1]);c=Convert.ToDouble(a[j]);
d=Convert.ToDouble(a[j+1]);
if (c>b&dAppendAllText(@"d:\"+s1,(n+j).ToString()+" ");
}
n+=a.Length;
}
Console.ReadKey(true);
}
}
}
Natija:
File 22. Haqiqiy sonlar fayli berilgan. Dastlabki faylning barcha lokal ekstremumlari nomerini kamayish tartibida o’zida aks ettiruvchi yangi butun fayl hosil qilinsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_22
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',','};double d=0,b,c=0;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();int i,j,n=0,l;
Console.Write("Yaratiladigan fayl nomini kiriting: ");
s1=Console.ReadLine();
string [] h=File.ReadAllLines(@"d:\"+s);
for (i=h.Length-1;i>=0;i--)
{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
n+=a.Length;
}
for (i=h.Length-1;i>=0;i--)
{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
b=Convert.ToDouble(a[a.Length-1]);
if (i!=h.Length-1) 
{
if ((cb)|(c>d&dAppendAllText(@"d:\"+s1,(n).ToString()+" ");
c=Convert.ToDouble(a[a.Length-2]);
if ((cAppendAllText(@"d:\"+s1,(n-1).ToString()+" ");
}
n-=a.Length;
for (j=a.Length-2;j>0;j--)
{
b=Convert.ToDouble(a[j-1]);c=Convert.ToDouble(a[j]);
d=Convert.ToDouble(a[j+1]);
if ((c>b&dc))File.AppendAllText(@"d:\"+s1,(n+j).ToString()+" ");
}
}
Console.ReadKey(true);
}
}
}
Natija:
File 23. Haqiqiy sonlar fayli berilgan. Dastlabki faylning barcha kamayish tartibidagi ketma-ketliklari uzunligini o’zida aks ettiruvchi yangi butun fayl hosil qilinsin. Masalan, 1,7; 4,5; 3,4; 2,2; 8,5; 1,2 elementli fayl uchun natijaviy fayl quyidagicha bo’lishi kerak: 3, 2
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_23
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',','};double b,c=0;
int i,j,n=1;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
Console.Write("Yaratiladigan fayl nomini kiriting: ");
s1=Console.ReadLine();
string [] h=File.ReadAllLines(@"d:\"+s);
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
b=Convert.ToDouble(a[0]);
if (i!=0) if (c>b|(c==b&n!=1)) n++;else {if (n!=1)File.AppendAllText(@"d:\"+s1,n.ToString()+" ");n=1;}
for (j=0;j{
b=Convert.ToDouble(a[j]);c=Convert.ToDouble(a[j+1]);
if (celse {if (n!=1)File.AppendAllText(@"d:\"+s1,n.ToString()+" ");n=1;}
}
if (i==h.Length-1&b>=c&n!=1)File.AppendAllText(@"d:\"+s1,n.ToString()+" ");
}
Console.ReadKey(true);
}
}
}
Natija:
File 24. Haqiqiy sonlar fayli berilgan. Dastlabki faylning barcha monoton ketma-ketliklari uzunligini o’zida aks ettiruvchi yangi butun fayl hosil qilinsin. Masalan, 1,7; 4,5; 3,4; 2,2; 8,5; 1,2 elementli fayl uchun natijaviy fayl quyidagicha bo’lishi kerak: 2, 3, 2, 2

Download 64,29 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish