Last active
December 17, 2015 07:09
-
-
Save Evshved/5570344 to your computer and use it in GitHub Desktop.
mas(A)+mas(B)=mas(C).
n(A)+n(B)=(n+1 or n)C, N row belongs whole numbers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| program adding_bitmaps; | |
| uses crt; | |
| var A,B:array [1..10] of byte; | |
| C:array[1..11] of byte; | |
| count_mas,count_dig,tip,time_count:byte; | |
| Begin | |
| read(tip); | |
| for count_mas:=1 to tip do | |
| begin | |
| A[count_mas]:=random(2); | |
| B[count_mas]:=random(2); | |
| end; | |
| A[tip+1]:=1; | |
| B[tip+1]:=1; | |
| write(' '); | |
| for time_count:=tip+1 downto 1 do | |
| begin | |
| write(A[time_count]:2); | |
| end; | |
| writeln; | |
| write(' '); | |
| for time_count:=tip+1 downto 1 do | |
| begin | |
| write(B[time_count]:2); | |
| end; | |
| count_mas:=0; | |
| while count_mas<>(tip+2) do | |
| begin | |
| count_mas:=count_mas+1; | |
| if (A[count_mas]+B[count_mas]=0) and (count_dig=1) then | |
| begin | |
| C[count_mas]:=1; | |
| count_dig:=0; | |
| continue; | |
| end; | |
| if (A[count_mas]+B[count_mas]=2) and (count_dig=0) then | |
| begin | |
| C[count_mas]:=0; | |
| count_dig:=1; | |
| continue; | |
| end; | |
| if (A[count_mas]+B[count_mas]=1) and (count_dig=1) then | |
| begin | |
| C[count_mas]:=0; | |
| count_dig:=1; | |
| continue; | |
| end; | |
| if (A[count_mas]+B[count_mas]=1) and (count_dig=0) then | |
| begin | |
| C[count_mas]:=1; | |
| continue; | |
| end; | |
| if (A[count_mas]+B[count_mas]=2) and (count_dig=1) then | |
| begin | |
| C[count_mas]:=1; | |
| count_dig:=1; | |
| continue; | |
| end; | |
| if (A[count_mas]+B[count_mas]=2) and (count_dig=0) then | |
| begin | |
| C[count_mas]:=0; | |
| count_dig:=1; | |
| continue; | |
| end; | |
| end; | |
| writeln; | |
| for time_count:=tip+2 downto 1 do | |
| begin | |
| write(C[time_count]:2); | |
| end; | |
| End. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment