19
While dövr operatoru 1) Verilmiş ədədin rəqəmləri arasında “5” rəqəmi varmı? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace while_1 { class Program { static void Main(string[] args) { // 1. Verilmiş ədədin rəqəmləri arasında “5” rəqəmi varmı? int eded = int.Parse(Console.ReadLine()); int k = 0; bool f = false; while (eded>0) { k = eded % 10; eded = eded / 10; if (k==5) { f = true; } } if (f == true) Console.WriteLine("Beli"); else Console.WriteLine("Xeyr"); Console.ReadKey(); } } } 2) Verilmiş ədəddə tək rəqəmlərin sayını tapın. using System;

While Dovr Operatoru

Embed Size (px)

Citation preview

While dövr operatoru

1) Verilmiş ədədin rəqəmləri arasında “5” rəqəmi varmı?using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_1{ class Program { static void Main(string[] args) { // 1. Verilmiş ədədin rəqəmləri arasında “5” rəqəmi varmı? int eded = int.Parse(Console.ReadLine()); int k = 0; bool f = false; while (eded>0) { k = eded % 10; eded = eded / 10; if (k==5) { f = true; } } if (f == true) Console.WriteLine("Beli"); else Console.WriteLine("Xeyr"); Console.ReadKey();

} }}2) Verilmiş ədəddə tək rəqəmlərin sayını tapın.using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_2{ class Program { static void Main(string[] args)

{ //2. Verilmiş ədəddə tək rəqəmlərin sayını tapın. int n = int.Parse(Console.ReadLine()); int k = 0; int say = 0;

while (n>0) { k = n % 10; n = n / 10; if (k%2!=0) { say++; } } Console.WriteLine("Tek reqemlerin sayi: "+say); Console.ReadKey(); } }}3) Verilmiş ədəddə cüt rəqəmlərin sayını tapın.using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_3{ class Program { static void Main(string[] args) { // 3. Verilmiş ədəddə cüt rəqəmlərin sayını tapın. int n = int.Parse(Console.ReadLine()); int k = 0; int say = 0;

while (n > 0) { k = n % 10; n = n / 10; if (k % 2 == 0) { say++; } }

Console.WriteLine("Cut reqemlerin sayi: " + say); Console.ReadKey(); } }}4) Verilmiş ədəddə “0” və “5” –dən fərqli neçə rəqəm var?using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_4{ class Program { static void Main(string[] args) { // 4. Verilmiş ədəddə “0” və “5” –dən fərqli neçə rəqəm var? int n = int.Parse(Console.ReadLine()); int k = 0; int say = 0; while (n>0) { k = n % 10; n = n / 10; if (k!=0 && k!=5) { say++; } } Console.WriteLine("0 ve 5-den ferqli reqemlerin sayi: " + say); Console.ReadKey(); } }}5) Verilmiş ədəddə “5”-dən böyük neçə rəqəm var?using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_5{ class Program { static void Main(string[] args)

{ // 5. Verilmiş ədəddə “5”-dən böyük neçə rəqəm var? int n = int.Parse(Console.ReadLine()); int k = 0; int say = 0;

while (n > 0) { k = n % 10; n = n / 10; if (k>5) { say++; } } Console.WriteLine("5-den boyuk reqemlerin sayi: " + say); Console.ReadKey(); } }}6) Verilmiş ədədi tərsinə düzün. using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_6{ class Program { static void Main(string[] args) { // 6. Verilmiş ədədi tərsinə düzün. int a = int.Parse(Console.ReadLine()); int b = 0; int c = a; int d = 1; int e = 1;

while (a > 0) { b = a % 10; a = a / 10; e = e * 10;

d = (d * 10 + b) % e; } Console.WriteLine("Ededin tersi: "+d); Console.ReadKey(); } }}7) Verilmiş ədədin tərsi “2000”-dən kiçikdirmi?using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_7{ class Program { static void Main(string[] args) { // 7. Verilmiş ədədin tərsi “2000”-dən kiçikdirmi? int a = int.Parse(Console.ReadLine()); int b = 0; int c = a; int d = 1; int e = 1;

while (a > 0) { b = a % 10; a = a / 10; e = e * 10; d = (d * 10 + b) % e; } Console.WriteLine("Ededin tersi: " + d); Console.WriteLine(); if (d<2000) { Console.WriteLine("Ededin tersi 2000-den kicikdir: " + d); } else Console.WriteLine("Ededin tersi 2000-den Boyukdur: " + d); Console.ReadKey(); } }

}8) Verilmiş ədədin tərsi “7”-yə bölünürmü?using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_8{ class Program { static void Main(string[] args) { //8. Verilmiş ədədin tərsi “7”-yə bölünürmü? int a = int.Parse(Console.ReadLine()); int b = 0; int c = a; int d = 1; int e = 1;

while (a > 0) { b = a % 10; a = a / 10; e = e * 10; d = (d * 10 + b) % e; } Console.WriteLine("Ededin tersi: " + d); Console.WriteLine(); if (d % 7 == 0) { Console.WriteLine("Beli"); } else Console.WriteLine("Xeyr"); Console.ReadKey(); } }}9) Verilmiş ədədin üzərinə tərsini əlavə edin.using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_9{ class Program { static void Main(string[] args) { // 9. Verilmiş ədədin üzərinə tərsini əlavə edin. int a = int.Parse(Console.ReadLine()); int b = 0; int c = a; int d = 1; int e = 1; int yekun;

while (a > 0) { b = a % 10; a = a / 10; e = e * 10; d = (d * 10 + b) % e; } Console.WriteLine("Ededin tersi: " + d); yekun = c + d; Console.WriteLine("Tersi ile ozunun cemi: " + yekun); Console.ReadKey(); } }}10) Verilmiş ədədin sonuncu rəqəmini ləğv edin.using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_10{ class Program { static void Main(string[] args) { //10. Verilmiş ədədin sonuncu rəqəmini ləğv edin. int a = int.Parse(Console.ReadLine()); a = a / 10;

Console.WriteLine("Sonuncu reqem legv edildi: " + a); Console.ReadKey(); } }}11) Verilmiş ədədin son rəqəmini ləğv edib nəticənin rəqəmləri cəmini tapın.using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_11{ class Program { static void Main(string[] args) { //11. Verilmiş ədədin son rəqəmini ləğv edib nəticənin rəqəmləri cəmini tapın. int a = int.Parse(Console.ReadLine()); a = a / 10; //sonuncu reqem legv edildi Console.WriteLine("Sonuncu reqem legv edildi: " + a); int b = 0; int cem = 0; while (a>0) { b = a % 10; a = a / 10; cem = cem + b; }

Console.WriteLine("Reqemlerinin cemi: " + cem); Console.ReadKey(); } }}12) Verilmiş ədədin “5”-dən fərqli rəqəmləri cəmini tapın.using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_12{ class Program {

static void Main(string[] args) { //12. Verilmiş ədədin “5”-dən fərqli rəqəmləri cəmini tapın. int a = int.Parse(Console.ReadLine()); int b = 0; int cem = 0; while (a > 0) { b = a % 10; a = a / 10; if (b!=5) { cem = cem + b; } }

Console.WriteLine("5-den ferqli Reqemlerinin cemi: " + cem); Console.ReadKey(); } }}13) Verilmiş ədədin “0” və “5”-dən fərqli rəqəmləri cəmini tapın.using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_13{ class Program { static void Main(string[] args) {

//13. Verilmiş ədədin “0” və “5”-dən fərqli rəqəmləri cəmini tapın. int a = int.Parse(Console.ReadLine()); int b = 0; int cem = 0; while (a > 0) { b = a % 10; a = a / 10; if (b!=0 && b!=5) {

cem = cem + b; } }

Console.WriteLine("Reqemlerinin cemi: " + cem); Console.ReadKey(); } }}14) Verilmiş ədədin kvadratının rəqəmləri cəmini tapın.using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_14{ class Program { static void Main(string[] args) { //14. Verilmiş ədədin kvadratının rəqəmləri cəmini tapın. int a = int.Parse(Console.ReadLine()); a = a * a; //kvadrata yukseldirem Console.WriteLine("verilmiw ededin kvadrati: " + a); int b = 0; int cem = 0; while (a > 0) { b = a % 10; a = a / 10; cem = cem + b; }

Console.WriteLine("Reqemlerinin cemi: " + cem); Console.ReadKey(); } }}15) Verilmiş ədədin polindromluq şərtinin yoxlayın. using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_15{ class Program { static void Main(string[] args) { // 15. Verilmiş ədədin polindromluq şərtinin yoxlayın. int a = int.Parse(Console.ReadLine()); int b = 0; int c = a; int d = 1; int e = 1; bool f = true;

while (a > 0) { b = a % 10; a = a / 10; e = e * 10; d = (d * 10 + b) % e; if (c == d) f = true; else f = false; } if (f == true) {

Console.WriteLine("Polidromdur"); }

else Console.WriteLine("Polidrom deyil"); Console.ReadKey(); } }}16) Verilmiş ədəddə yanaşı gələn eyni rəqəm varmı?using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_16{ class Program { static void Main(string[] args) {

//16. Verilmiş ədəddə yanaşı gələn eyni rəqəm varmı? int a = int.Parse(Console.ReadLine()); int b = 0; int c = 0; int say = 0; bool f = false; while (a>0) { b = a % 10; a = a / 10; c = a % 10; if (b==c) { f = true; say++; }

} if (f==true) { Console.WriteLine("Beli var sayi: "+say); } else Console.WriteLine("Yoxdur"); Console.ReadKey(); } }}17) Verilmiş ədəddə “0” rəqəmini ləğv et.using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_17{ class Program { static void Main(string[] args) { //17. Verilmiş ədəddə “0” rəqəmini ləğv et. int a = int.Parse(Console.ReadLine()); int b = 0; int c = 1; int d = 1;

int e = 1; int b1 = 0; int e1 = 1;

while (a > 0) { b = a % 10; a = a / 10; e = e * 10; if (b!=0) { d = (d * 10 + b) % e; // edede 0 lari legv edib tersini tapiram } } while (d>0) { b1 = d % 10; d = d / 10; e1 = e1 * 10; c = (c * 10 + b1) % e1; } Console.WriteLine("0-lar legv edildi: " + c); Console.ReadKey(); } }}18) Verilmiş ədəddin rəqəmləri cəmi cüt ədəddirmi?using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_18{ class Program { static void Main(string[] args) { //18. Verilmiş ədəddin rəqəmləri cəmi cüt ədəddirmi? int a = int.Parse(Console.ReadLine()); int b = 0; int cem = 0; while (a > 0)

{ b = a % 10; a = a / 10; cem = cem + b; } if (cem%2==0) { Console.WriteLine("Beli Reqemlerinin cemi cut ededdir: " + cem); } else Console.WriteLine("Xeyr Reqemlerinin cemi cut eded deyil: " + cem); Console.ReadKey(); } }}19) Verilmiş ədəddin rəqəmləri cəmi tək ədəddirmi?using System;using System.Collections.Generic;using System.Linq;using System.Text;

namespace while_19{ class Program { static void Main(string[] args) { //19. Verilmiş ədəddin rəqəmləri cəmi tək ədəddirmi? int a = int.Parse(Console.ReadLine()); int b = 0; int cem = 0; while (a > 0) { b = a % 10; a = a / 10; cem = cem + b; } if (cem % 2 != 0) { Console.WriteLine("Beli Reqemlerinin cemi tek ededdir: " + cem); } else Console.WriteLine("Xeyr Reqemlerinin cemi tek eded deyil: " + cem); Console.ReadKey(); } }}20) Verilmiş ədəddin ilk rəqəmi ilə son rəqəminin cəmi tək ədədirmi?

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

namespace while_20{ class Program { static void Main(string[] args) { //20. Verilmiş ədəddin ilk rəqəmi ilə son rəqəminin cəmi tək ədədirmi? int a = int.Parse(Console.ReadLine()); int b = 0; int c = a; int sonreqem; int cem = 0; while (a > 0) { b = a % 10; a = a / 10; } sonreqem = c % 10; cem = b + sonreqem; if (cem%2!=0) { Console.WriteLine("Beli tek ededdir: " + cem); } else Console.WriteLine("Xeyr tek eded deyil: " + cem); Console.ReadKey(); } }}