,   CyberForum.ru

- C++

C++ nxm http://www.cyberforum.ru/cpp-beginners/thread545946.html
, ) nxm. : , . =)
C++ n. n , 2, 3 5 #include<iostream> #include<vector> #include<cstdlib> using namespace std; int main() {int i,n,k; cout<<"n: "<<endl; cin>>n; http://www.cyberforum.ru/cpp-beginners/thread545929.html
C++ , , ++
program Virazhenie; //uses crt; type tmatr = array of real; var F, Q, A1, A2, A3, A4, A5, x, y, z, x1: real; i, j: integer; g: boolean; a, b, c, d: array of real;
C++ . .
. . . . , . . . ...
C++ Builder , http://www.cyberforum.ru/cpp-beginners/thread545904.html
NxM. B, k- 0, k- , 1 . //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1mass.h" //--------------------------------------------------------------------------- #pragma...
C++ , . . n.

-==-
FAQ
12.04.2012, 16:49    
,
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
// ÃÎÑÒ 28147-89.cpp : Defines the entry point for the console application.
//
 
#include <cstdio>
#include <iostream>
using namespace std;
 
// ò*áëèö* ç*ìå*
 char Tab_Z[8][16] =
 {
  0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,
  0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,
  0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,
  0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,
  0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,
  0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,
  0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,
  0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF
 };
 
// êëþ÷èê
 unsigned long key[8] =
 {
  0x0123,
  0x4567,
  0x89AB,
  0xCDEF,
  0x0123,
  0x4567,
  0x89AB,
  0xCDEF
 };
 
 
//---------------------------------------------------------------------------
// âçÿòî èç õåëï*, îïðåäåëÿåì ð*çìåð ô*éë*
long filesize(FILE *stream)
{
 long curpos, length;
 curpos = ftell(stream);
 fseek(stream, 0L, SEEK_END);
 length = ftell(stream);
 fseek(stream, curpos, SEEK_SET);
 return length;
}
 
// ôó*êöèÿ, ðå*ëèçóþù*ÿ ð*áîòó ÃÎÑÒ 28147-89 â ðåæèìå ïðîñòîé ç*ìå*û
void rpz(int rezh, char* opener, char* saver)
{
    int i,q,k;
    FILE *f_begin, *f_end; // ïîòîêè äëÿ èñõîä*îãî è êî*å÷*îãî ô*éëîâ
    char N[4]; // 32-ð*çðÿä*ûé **êîïèòåëü,
    unsigned long n1=0, n2=0, SUM232=0; // **êîïèòåëè N1, N2, è ñóìì*òîð
 
    // îòêðûâ*åì ô*éëû
    f_begin = fopen (opener,"rb");
    f_end = fopen (saver,"wb");
 
    // îïðåäåëèì êîëè÷åñòâî áëîêîâ
    float blokoff;
    blokoff = 8*filesize(f_begin);
    blokoff = blokoff/64;
    int block = blokoff;
    if (blokoff-block>0) 
        block++;
    
    int sh;
    if (filesize(f_begin)>=4) 
        sh = 4; 
    else 
        sh = filesize(f_begin);
    int sh1 = 0;
    int flag=0;
 
    // **÷*åì ñ÷èòûâ**èå è ïðåîáð*çîâ**èå áëîêîâ
    // ïðèñóòñòâóþò ïðîâåðêè ** ïîë*îòó áëîêîâ, ÷òîáû ñ÷èò*òü òîëüêî *óæ*îå êîëè÷åñòâî áèò
 for (i=0; i<block; i++)
 {
  // ç*ïèñûâ*åì â **êîïèòåëü N1
  for (q=0; q<4; q++) *((char *)&N+q) = 0x00;
  if ((sh1+sh)<filesize(f_begin))
  {
   fread (N,sh,1,f_begin);
   sh1+=sh;
  }
  else
  {
   sh=filesize(f_begin)-sh1;
   fread (N,sh,1,f_begin);
   flag=1;
  }
  n1 = *((unsigned long *)&N);
 
  // ç*ïèñûâ*åì â **êîïèòåëü N2
  for (q=0; q<4; q++) *((char *)&N+q) = 0x00;
  if ((sh1+sh)<filesize(f_begin))
  {
   fread (N,sh,1,f_begin);
   sh1+=sh;
  }
  else
  {
   if (flag==0)
   {
    sh=filesize(f_begin)-sh1;
    fread (N,sh,1,f_begin);
   } 
  }
  n2 = *((unsigned long *)&N);
 
  // 32 öèêë* ïðîñòîé ç*ìå*û
  // êëþ÷ ñ÷èòûâ*åì â òðåáóåìîì ÃÎÑÒîì ïîðÿäêå
  int c = 0;
  for (k=0; k<32; k++)
  {
   if (rezh==1) { if (k==24) c = 7; }
    else { if (k==8) c = 7; }
 
   // ñóììèðóåì â ñóìì*òîðå ÑÌ1
   SUM232 = key[c] + n1;
 
   // ç*ìå*ÿåì ïî ò*áëèöå ç*ìå*
   char first_byte=0,second_byte=0,zam_symbol=0;
   int n = 7;
   for (int q=3; q>=0; q--)
   {
    zam_symbol = *((char *)&SUM232+q);
    first_byte = (zam_symbol & 0xF0) >> 4;
    second_byte = (zam_symbol & 0x0F);
    first_byte = Tab_Z[n][first_byte];
    n--;
    second_byte = Tab_Z[n][second_byte];
    n--;
    zam_symbol = (first_byte << 4) | second_byte;
    *((char *)&SUM232+q) = zam_symbol;
   } 
   
   SUM232 = (SUM232<<11)|(SUM232>>21); // öèêëè÷åñêèé ñäâèã ** 11
   SUM232 = n2^SUM232; // ñêë*äûâ*åì â ñóìì*òîðå ÑÌ2
 
   if (k<31)
   {
    n2 = n1;
    n1 = SUM232;
   }
   if (rezh==1)
   {
    if (k<24)
    {
     c++;
     if (c>7) c = 0;
    }
    else
    {
     c--;
     if (c<0) c = 7;
    }
   }
   else
   {
    if (k<8)
    {
     c++;
     if (c>7) c = 0;
    }
   else
   {
    c--;
    if (c<0) c = 7;
   }
  }
 }
 n2 = SUM232;
 
 // âûâîä ðåçóëüò*ò* â ô*éë
  char sym_rez;
  for (q=0; q<=3; q++)
  {
   sym_rez = *((char *)&n1+q);
   fprintf(f_end, "%c", sym_rez);
  }
  for (q=0; q<=3; q++)
  {
   sym_rez = *((char *)&n2+q);
   fprintf(f_end, "%c", sym_rez);
  }
 }
 fclose (f_begin);
 fclose (f_end);
}
 
//---------------------------------------------------------------------------
// âûáèð*åì øèôðîâ**èå èëè ð*ñøèôðîâ**èå
int main(int argc, char * argv [])
{
    system("chcp 1251");
    int rezhim;
    do
    {
        cout<<"Áóäüë*ñê*, âèáåð³òü ðåæèì ðîáîòû:\n"
            "Øèôðóâ***ÿ - 1\nÐîçøèôðóâ***ÿ - 2\n";
        cin>> rezhim;
    } 
    while ((rezhim!=1)&&(rezhim!=2)); // ïîâòîðÿåì äî òåõ ïîð, ïîê* *å áóäåò ââåäå*î 1 èëè 
    
    // âûáèð*åì èñõîä*ûé è êî*å÷*ûé ô*éëû (ñëýø '\' â ïóòè ïèñ*òü ê*ê '\\') 
    char open_str[50], save_str[50];
    cout<<"\nÂâåä³òü ïóòü äî ïåðâè**îãî ô*éëó\n";
    cin>> open_str;
    cout<<"\nÂâåäèòå ïóòü äî ô*éëó, â ÿêèé òðåá* ç*ïèñ*òè ðåçóëüò*ò\n";
    cin>> save_str;
    rpz(rezhim, open_str, save_str); // ç*ïóñê*åì ÐÏÇ
    system("pause");
    return 0;
}
    
 
: 03:16. GMT +3.
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
@Mail.ru