program an;
var n:integer;
s1,s2:string;
i,j:integer;
begin
s1[1]:='*';
s2[1]:=' ';
for j:=2 to n do
begin
if s1[j-1]='*' then
s1[j]:=' '
else
s1[j]:='*';
if s2[j-1]='*' then
s2[j]:=' '
else
s2[j]:='*';
end;
j:=1;
for i:=1 to n do
begin
if j=1 then
begin
writeln(s1);
j:=0;
end
else
begin
j:=1;
writeln(s2);
end
end;
end.
Объяснение:
#include <iostream>
using namespace std;
int main()
{
float a;
int b;
double c;
cout<<"Choose mode: 1 - KB to bit, 2 - bit to KB :";
cin>>b;
switch(b)
{
case 1:
cout<<"Enter KByte count :"; cin>>a;
c = a * 8 * 1024;
cout <<a<<" KByte = "<<c<<" bit";
break;
case 2:
cout<<"Enter bit count :"; cin>>a;
c = a /1024/8;
cout <<a<<" bit= "<<c<<" KByte";
break;
}
return 0;
}
Объяснение:
var a, b, с: integer;
begin
write('Введите два числа: ');
readln(a, b);
if a < b then с := a + 1 else с := b + 1;
repeat с := с - 1
until (a mod с = 0) and (b mod с = 0);
write('NOD = ', с)
end.
//2. Алгоритм с вычитанием (цикл while)
var a, b: integer;
begin
write('a = ');
readln(a);
write('b = ');
readln(b);
while a <> b do
if a > b then
a := a - b
else
b := b - a;
writeln('NOD = ', a);
end.