#include <iostream> #include <cstdlib> using namespace std; int main() { int A [6][6]; int B[6]; //Massivty toltyru for(int i=0;i<6;i++) for(int j=0;j<6;j++) A[i][j]= rand()%6; for(int i=0;i<6;i++){ for(int j=0;j<6;j++) cout<<A[i][j]<<"\t"; cout<<endl;} cout<<endl; for(int i=0;i<6;i++) B[i]=0; for(int i=0;i<6;i++){ for(int j=0;j<6;j++) { switch(ji) { case 0:if(A[i][j]==0) B[ji]+=1;break; case 1:if(A[i][j]==0) B[ji]+=1;break; case 2:if(A[i][j]==0) B[ji]+=1;break; case 3:if(A[i][j]==0) B[ji]+=1;break; case 4:if(A[i][j]==0) B[ji]+=1;break; case 5:if(A[i][j]==0) B[ji]+=1;break; } } } for(int i=0;i<6;i++) cout<<B[i]<<"\t"; } Closed due to the fact that it was off topic by Nicolas Chabanovsky ♦ Jun 13 '16 at 7:31 .
- Most likely, this question does not correspond to the subject of Stack Overflow in Russian, according to the rules described in the certificate .
- According to community rules, questions should not be reduced to completing tasks for students. - Nicolas Chabanovsky ♦
|
1 answer
Look, there is nothing difficult there, if you know pascal, you will not be able to translate labor. cout<< - you change it to output as in pascal (it seems like there is a writeline, I don’t remember exactly) for(int i:=0;i<6;i++) is equivalent to for i=0 to 6 do begin (see did not write) switch is like some kind of check, depending on what I received (from 0 to 5) a certain action is performed (in this case the same thing, and I don’t see any sense in the switch) - you can replace it with an ordinary if'om . The rest, in essence, is the same, A, B are arrays, two-dimensional and single
= это := B[ji]+=1 - это B[ji]:=B[ji]+1; break; - это выход type A = array [1..6, 1..6] of integer; B = array [1..6] of integer; integer i,j; ... for i:=0 to 6 do for j:=0 to 6 do A[i][j]:=random() mod 6; // vot tut ne uveren for i:=0 to 6 do for j:=0 to 6 do writeline(A[i][j]); for i:=0 to 6 do B[i]:=0; for i:=0 to 6 do for j:=0 to 6 do if ( (ji)>0 and (ji)<6) then if A[i][j] =0 then begin B[ji]=B[ji]+1; break; // tut ne uveren, poishite v gugle vixod end; for i:=0 to 6 do writeline(B[i]); write right here, minor mistakes fix it yourself
|