Определите, какое значение будет выведено на экран в результате выполнения приведенной ниже последовательности операторов: a:=1; b:=1; While a<=32 do a:=a×2 b:=b×a Write (b)
{таким образом, фразу " работа на завтра." можно закодировать как "11000100-11101110-11101100-11100000-11111000-11101101-11111111-11111111-100000-11110000-11100000-11100001-11101110-11110010-11100000-100000-11101101-11100000-100000-11100111-11100000-11100010-11110010-11110000-11100000-101110-".}
{данная программа переводит любое сочетание символов ascii в систему счисления заданную пользователем.}
//pascal abc.net v3.0 сборка 1111
var
a,i,b,r,n,j,bug: integer;
s,se,slo,slof: string;
procedure preob(var a,b,n: integer; var se: string);
begin
repeat
b: =a mod n;
a: =a div n;
str(b,se);
s+=se;
until (a< =n-1);
end;
beginreadln(slo);
readln(n);
for j: =1 to length(slo) do
begin;
a: =ord(slo[j]);
preob(a,b,n,se);
str(a,se);
s+=se;
for i: =1 to length(s) div 2 do
begin;
se: =s[i];
s[i]: =s[length(s)-i+1];
s[length(s)-i+1]: =se[1];
end;
write(s,'-');
slof: =slof+s;
delete(s,1,length(s));
end;
end.
пример ввода:
работа на завтра.
2
пример вывода:
11000100-11101110-11101100-11100000-11111000-11101101-11111111-11111111-100000-11110000-11100000-11100001-11101110-11110010-11100000-100000-11101101-11100000-100000-11100111-11100000-11100010-11110010-11110000-11100000-101110-
{таким образом, фразу " работа на завтра." можно закодировать как "11000100-11101110-11101100-11100000-11111000-11101101-11111111-11111111-100000-11110000-11100000-11100001-11101110-11110010-11100000-100000-11101101-11100000-100000-11100111-11100000-11100010-11110010-11110000-11100000-101110-".}
#include
#include
#include
#include
#include
#include
typedef struct
{
char imya[40];
char familiya[40];
char otchestvo[40];
int telefon;
int texpasport;
float pages ;
}gor;
void form(char mass[10], char *imya, char *familiya, char *otchestvo, int telefon, int texpasport)
{
file *f;
gor y;
int i;
if ((f=fopen(mass,"w"))==null) exit(1);
for (i=1; i< =3; i++)
{
cout< < "vvedite imya: ";
cin> > imya;
cout< < "vvedite familiya: ";
cin> > familiya;
cout< < "vvedite otchestvo: ";
cin> > otchestvo;
cout< < "vvedite telefon: ";
cin> > telefon;
cout< < "vvedite texpasport: ";
cin> > texpasport;
fwrite(& y,sizeof(gor),1,f);
if(ferror(f)! =null)
exit(2);
}
fclose(f);
}
void vivod(char mass[50])
{
file *f;
gor z;
if ((f=fopen(mass, "r"))==null) exit(3);
cout< < "fail: "<
while (! feof(f)) {
fread (& z,sizeof(gor),1,f);
if (! feof(f))
{
cout< < "imya: "<
cout< < "familiya: "<
cout< < "otchestvo: "<
cout< < "telefon: "<
cout< < "texpasport: "<
}
fclose(f);
}
}
void del(char fo[10], char fi[10])
{
file *f1,*f2;
gor d;
//char temp[40];
if ((f1=fopen(fi,"r"))==null) exit(4);
if ((f2=fopen(fo,"w"))==null) exit(5);
//cout < < "vvedite nazvanie na ydalenie - ";
//cin > > temp;
for (int i=0; i< 3; i++)
{
fread(& d,sizeof(gor),1,f1);
if (feof(f1)) break;
if (i> 2)
fwrite (& d,sizeof(gor),1,f2);
}
fclose(f2);
fclose(f1);
}
void dobav(char fi[10], char fo[10],char *imya, char *familiya, char *otchestvo, int telefon, int texpasport)
{
int q;
int i;
gor d;
file *f1,*f2;
char temp[40];
if ((f1=fopen(fi, "r"))==null) exit(4);
if ((f2=fopen(fo,"r+"))==null) exit(5);
cout < < "vvedite familiu, pered kotorym nuzno dobavit element: ";
cin > > temp;
for (i=0; i< 10; i++)
{
fread(& d,sizeof(gor),1,f2);
if (feof(f2)) break;
if (strcmp(d.familiya, temp)) break;
q=i;
}
for (i=0; i< 10; i++)
{
if (feof(f2)) break;
fwrite (& d,sizeof(gor),1,f2);
if (i==q-1)
{
cout< < "vvedite imya: ";
cin> > imya;
cout< < "vvedite familiya: ";
cin> > familiya;
cout< < "vvedite otchestvo: ";
cin> > otchestvo;
cout< < "vvedite telefon: ";
cin> > telefon;
cout< < "vvedite texpasport: ";
cin> > texpasport;
cout <
}
}
fclose(f2);
fclose(f1);
}
void main()
{
int n=10;
//cout < < "vvedite kol-vo zapisey: - ";
//cin> > n;
//cout <
form("f1.txt",n);
vivod("f1.txt");
del("f1.txt","f2.txt");
cout < < "posle udalenia: \n";
vivod("f2.txt");
getch();
n=1;
system("cls");
dobav ("f2.txt","f2.txt");
cout < < "posle dobavlenia: \n";
vivod ("f2.txt");
getch();
}