|
Kompyuter tizimlari kafedrasi
|
bet | 122/154 | Sana | 08.01.2024 | Hajmi | 5,29 Mb. | | #131939 |
Bog'liq MajmuaCHiziqli dastur yaratish
Ikkita sonni qo’shish
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Birinchi sonni kiriting");
string S1 = Console.ReadLine();
int a = int.Parse(S1);
Console.WriteLine("Ikkinchi sonni kiriting ");
string S2 = Console.ReadLine();
int b = int.Parse(S2);
int c = a + b;
Console.WriteLine(a.ToString() + " + " + b.ToString() + " = " + c.ToString());
Console.ReadLine();
}
}
}
2. Razryadli amallar
int x1 = 2; //010
int y1 = 5;//101
Console.WriteLine(x1&y1); // 0
int x2 = 4; //100
int y2 = 5; //101
Console.WriteLine(x2 & y2); // 4
int x1 = 2; //010
int y1 = 5;//101
Console.WriteLine(x1|y1); // 7 - 111
int x2 = 4; //100
int y2 = 5;//101
Console.WriteLine(x2 | y2); // 5 – 101
int x = 45; // форме 101101
int key = 102; // 1100110
int encrypt = x ^ key; // 1001011 ypki 75
Console.WriteLine("Зашифрованное число: " +encrypt);
int decrypt = encrypt ^ key; // 45
Console.WriteLine("Расшифрованное число: " + decrypt);
int x = 12; // 00001100
Console.WriteLine(~x); // 11110011 yoki -13
int x = 12;
int y = ~x;
y += 1;
Console.WriteLine(y); // -12
3. Mantiqiy amallar
int a = 10;
int b = 4;
bool c = a == b; // false
int a = 10;
int b = 4;
bool c = a != b; // true
bool d = a!=10; // false
int a = 10;
int b = 4;
bool c = a < b; // false
int a = 10;
int b = 4;
bool c = a > b; // true
bool d = a > 25; // false
int a = 10;
int b = 4;
bool c = a <= b; // false
bool d = a <= 25; // true
int a = 10;
int b = 4;
bool c = a >= b; // true
bool d = a >= 25; // false
bool x1 = (5 > 6) | (4 < 6); // 5 > 6 - false, 4 < 6 - true
bool x2 = (5 > 6) | (4 > 6); // 5 > 6 - false, 4 > 6 - false
bool x1 = (5 > 6) & (4 < 6); // 5 > 6 - false, 4 < 6 - true
bool x2 = (5 < 6) & (4 < 6); // 5 < 6 - true, 4 < 6 - true
bool x1 = (5 > 6) || (4 < 6); // 5 > 6 - false, 4 < 6 - true
bool x2 = (5 > 6) || (4 > 6); // 5 > 6 - false, 4 > 6 - false
bool x1 = (5 > 6) && (4 < 6); // 5 > 6 - false, 4 < 6 - true
bool x2 = (5 < 6) && (4 < 6); // 5 < 6 - true, 4 < 6 - true
bool a = true;
bool b = !a; // false
bool x5 = (5 > 6) ^ (4 < 6); // 5 > 6 - false, 4 < 6 - true
bool x6 = (50 > 6) ^ (4 / 2 < 3); // 50 > 6 - true, 4/2 < 3 - true false
|
| |