I had a problem when I was working on the p1319 compression technique
The problem was as follows:
Let a Chinese character consist of a lattice pattern of N*N zeros and ones.
We generate the compression code according to the following rules. A continuous set of values: counting from the first symbol in the first row of a Chinese character lattice pattern, from left to right and from top to bottom in writing order. The first number means a series of zeros, the second number means a series of ones, the third number means a series of zeros, the fourth number means a series of ones, and so on...
For example, the following Chinese character lattice pattern:
0001000
0001111
0001000
0001000
0001000
0001000
1111111
The corresponding compression code is: 7 3 1 6 1 6 6 4 1 6 1 1 3 3 7}7 3 1 1 6 1 6 6 1 1 3 3 7(The first number is NN, and the rest are numbers that alternate between 0 and 1, Compression code Ensure N x N= sum of alternating numbers)
Input Format
Data input a line of integers separated by Spaces, indicating the compression code. The
output format
represents the final Chinese character lattice(with no Spaces between the lattice symbols).
Input/Output Example
Input #1
7 3 1 6 1 6 4 3 1 6 1 6 1 3 3 7
Output #1
0001000
0001000
0001111
0001000
0001000
0001000
1111111
Description
Info
Data assurance, 3≤N≤200.
When 7 3 1 6 1 6 4 3 1 6 1 1 6 1 1 3 3 7, Output is
0001000
0001000
0001111
0001000
0001000
0001000
0001000
1111111
There is an extra line; Other is < br / >(< del > I just embarrassing < del >) < br / >(< del > who can teach me < del >) < br / >
# # # code#include <iostream>
using namespace std;
int main(){
int n,a,num,b;
int c=1;
cin>>n;
for(int i=1;;i++){
cin>>a;
num+=a;
b++;
if(b%2==0){
for(int j=1;j<=a;j++){
cout<<"0";
c++;
if(c%n==1){
cout<<endl;
}
}
}
if(b%2!=0){
for(int j=1;j<=a;j++){
cout<<"1";
c++;
if(c%n==1){
cout<<endl;
}
}
}
if(num==n*n){
return 0;
}
}
}
My idea is to loop until the sum of all the input numbers is equal to n*n, and each time the little loop c is added n times to wrap the line
0 Answer
No answer yet
这家伙很懒，什么都没留下...