Dastur Muallifi Qoldoshev Olmos //Dasturlash Tili Java



Download 17,8 Kb.
Sana11.06.2022
Hajmi17,8 Kb.
#654484
Bog'liq
kampyuterni


//Dastur Muallifi Qoldoshev Olmos
//Dasturlash Tili Java
//Dastur maqsadi Ikkili o'nlik usuli bilan hisoblash dasturi
//Asosiy maqsad Ayirish amalini qo'shish amali yordamida xisoblash
import java.util.Scanner;
public class Main {

public static int maxx(int a, int b){


if (Math.abs(a)>=Math.abs(b)){
if (a>=0){
return a;
}else
return a*(-1);
}else if (b>=0) {
return b;
}else return b*(-1);
}

public static void main(String[] args){


Scanner krit =new Scanner(System.in);
System.out.println("Kampyuter ikkita son ustida amallarni qanday bajarilishini bilmoqchimisiz unda ikkita son kiriting ");

int a= krit.nextInt();


int b= krit.nextInt(),S=0,A=0,B=0;
int x=a;
int y=b;
S=a+b;
String olchami=String.valueOf((maxx(a,b)));
String olchami2=String.valueOf(S);
int k=olchami.length();
int kk=olchami2.length();

int mas[]=new int[(maxx(k,kk)*4+2)];


int mas2[]=new int[(maxx(k,kk)*4+2)];
int mas3[]=new int[(maxx(kk,k)*4+2)];

int i=0;


for (int p = 0; p < maxx(k,kk); p++) {
A=a%10; B=b%10;
if (x>=0){
switch (A){
case 0: {mas[i]=0; mas[i+1]=0; mas[i+2]=0; mas[i+3]=0;} break;
case 1: {mas[i]=1; mas[i+1]=0; mas[i+2]=0; mas[i+3]=0;} break;
case 2: {mas[i]=0; mas[i+1]=1; mas[i+2]=0; mas[i+3]=0;} break;
case 3: {mas[i]=1; mas[i+1]=1; mas[i+2]=0; mas[i+3]=0;} break;
case 4: {mas[i]=0; mas[i+1]=0; mas[i+2]=1; mas[i+3]=0;} break;
case 5: {mas[i]=1; mas[i+1]=0; mas[i+2]=1; mas[i+3]=0;} break;
case 6: {mas[i]=0; mas[i+1]=1; mas[i+2]=1; mas[i+3]=0;} break;
case 7: {mas[i]=1; mas[i+1]=1; mas[i+2]=1; mas[i+3]=0;} break;
case 8: {mas[i]=1; mas[i+1]=0; mas[i+2]=0; mas[i+3]=1;} break;
case 9: {mas[i]=1; mas[i+1]=0; mas[i+2]=0; mas[i+3]=1;} break;
}} else {
switch (A) {
case 0: {mas[i] = 1;mas[i + 1] = 1;mas[i + 2] = 1;mas[i + 3] = 1;}break;
case -1: {mas[i] = 0;mas[i + 1] = 1;mas[i + 2] = 1;mas[i + 3] = 1;}break;
case -2: {mas[i] = 1;mas[i + 1] = 0;mas[i + 2] = 1;mas[i + 3] = 1;}break;
case -3: {mas[i] = 0;mas[i + 1] = 0;mas[i + 2] = 1;mas[i + 3] = 1;}break;
case -4: {mas[i] = 1;mas[i + 1] = 1;mas[i + 2] = 0;mas[i + 3] = 1;}break;
case -5: {mas[i] = 0;mas[i + 1] = 1;mas[i + 2] = 0;mas[i + 3] = 1;}break;
case -6: {mas[i] = 1;mas[i + 1] = 0;mas[i + 2] = 0;mas[i + 3] = 1;}break;
case -7: {mas[i] = 0;mas[i + 1] = 0;mas[i + 2] = 0;mas[i + 3] = 1;}break;
case -8: {mas[i] = 0;mas[i + 1] = 1;mas[i + 2] = 1;mas[i + 3] = 0;}break;
case -9: {mas[i] = 0;mas[i + 1] = 1;mas[i + 2] = 1;mas[i + 3] = 0;}break;

}
}
if (y>=0){


switch (B){
case 0: {mas2[i]=0; mas2[i+1]=0; mas2[i+2]=0; mas2[i+3]=0;} break;
case 1: {mas2[i]=1; mas2[i+1]=0; mas2[i+2]=0; mas2[i+3]=0;} break;
case 2: {mas2[i]=0; mas2[i+1]=1; mas2[i+2]=0; mas2[i+3]=0;} break;
case 3: {mas2[i]=1; mas2[i+1]=1; mas2[i+2]=0; mas2[i+3]=0;} break;
case 4: {mas2[i]=0; mas2[i+1]=0; mas2[i+2]=1; mas2[i+3]=0;} break;
case 5: {mas2[i]=1; mas2[i+1]=0; mas2[i+2]=1; mas2[i+3]=0;} break;
case 6: {mas2[i]=0; mas2[i+1]=1; mas2[i+2]=1; mas2[i+3]=0;} break;
case 7: {mas2[i]=1; mas2[i+1]=1; mas2[i+2]=1; mas2[i+3]=0;} break;
case 8: {mas2[i]=0; mas2[i+1]=0; mas2[i+2]=0; mas2[i+3]=1;} break;
case 9: {mas2[i]=1; mas2[i+1]=0; mas2[i+2]=0; mas2[i+3]=1;} break;
}}else {
switch (B){
case 0: {mas2[i]=1; mas2[i+1]=1; mas2[i+2]=1; mas2[i+3]=1;} break;
case -1: {mas2[i]=0; mas2[i+1]=1; mas2[i+2]=1; mas2[i+3]=1;} break;
case -2: {mas2[i]=1; mas2[i+1]=0; mas2[i+2]=1; mas2[i+3]=1;} break;
case -3: {mas2[i]=1; mas2[i+1]=1; mas2[i+2]=0; mas2[i+3]=0;} break;
case -4: {mas2[i]=0; mas2[i+1]=0; mas2[i+2]=1; mas2[i+3]=0;} break;
case -5: {mas2[i]=1; mas2[i+1]=0; mas2[i+2]=1; mas2[i+3]=0;} break;
case -6: {mas2[i]=0; mas2[i+1]=1; mas2[i+2]=1; mas2[i+3]=0;} break;
case -7: {mas2[i]=1; mas2[i+1]=1; mas2[i+2]=1; mas2[i+3]=0;} break;
case -8: {mas2[i]=1; mas2[i+1]=1; mas2[i+2]=1; mas2[i+3]=0;} break;
case -9: {mas2[i]=1; mas2[i+1]=0; mas2[i+2]=0; mas2[i+3]=1;} break;
}}

if (x>=0){


mas[mas.length-1]=0;
mas[mas.length-2]=0;
}else {
mas[mas.length-1]=1;
mas[mas.length-2]=1;
}
if (b>=0){
mas2[mas.length-1]=0;
mas2[mas.length-2]=0;
}else {
mas2[mas.length-1]=1;
mas2[mas.length-2]=1;
}
a=a/10;
b=b/10;
i+=4;

}
for (int j = (mas.length-1); j >= 0; j--) {


System.out.print(mas[j]);
System.out.print(" ");
}
System.out.println();
for (int j = (mas2.length-1); j >= 0; j--) {
System.out.print(mas2[j]);
System.out.print(" ");
}
int n=0,r=0,t=0;
for (int j = 0; j <= (mas2.length-1); j++) {
r=mas[j]+mas2[j]+n;
if (r==1 || r==0){
mas3[j]=r;
n=0;
}else if (r==2){
n=1;
mas3[j]=0;
}else if (r==3){
mas3[j]=1;
n=1;
}
if(j==(mas2.length-1) && (r==2 || r ==3)){
int l=0;
mas3[l]+=1;
if (mas3[l]==2){
mas3[l]=0;
}
}
r=0;
}

System.out.println();


for (int j =(mas2.length-1) ; j >= 0; j--) {
System.out.print(mas3[j]);
System.out.print(" ");
}

System.out.println("4-bosqich To'g'ri kodga o'girish");


for (int j =(mas2.length-3) ; j >= 0; j--) {
if (mas3[0]==1 && mas3[1]==1){
if (mas3[j]==0){
mas3[j]=1;
}else if (mas3[j]==1){
mas3[j]=0;
}
}
}
for (int j =(mas2.length-3) ; j >= 0; j--) {
System.out.print(mas3[j]);
System.out.print(" ");
}

}
}
Download 17,8 Kb.

Do'stlaringiz bilan baham:




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