Click here to Skip to main content
15,883,647 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have to build a two dimensional table (0/1 at any position) of size N * N. With applying these first order constraints. Put table arbitrary lets say _Bool tab[N][N];

Write C code , For loops (Two of them ..) to restrict this table for the conditions are following :

1.For each i's from 0 to N, !all j == 0 and !all j ==1

a. No row should have all 1's.
b. No row should have all 0's.

2.For each i's between 0 to N , there exists at least one j such that tab[i][j] == 1

a.Each row should have at least one 1.

kindly help me. thanks.
Posted
Updated 20-Feb-15 17:44pm
v2
Comments
Richard MacCutchan 21-Feb-15 4:33am    
That star is to tell you that no one here is going to do your work for you. Please read the FAQ.

At least any Hint ?? Please .
 
Share this answer
 
Comments
Richard MacCutchan 22-Feb-15 4:08am    
Hint: draw the desired result on paper for say a 5 * 5 matrix. Fill in the required values based on your rules. From that you can deduce the algorithm that needs to be coded.
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
Comments
ALEX_CROME 21-Feb-15 10:45am    
It's not a homework. I'm in the middle of my project and requirement was that the table build has to be treated like just an Input which i did by using (assumes yes I'm doing model checking). But now I want to improve that using this idea that lets use these constraints and feed that to a SAT solver which in return will satisfy the constraints and then I'll check for some property and get a counterexample for the same. I'm unable to come up with a solution , actually i have more constraints on the building table but wanted basic constraints to be clear . I'm Not a C programmer and so now i have to tell declarative in C that these constraints met. I do't want to create a Table I have to just specify the constraints. It will be great help if u suggest something rather than pointing out that this is Homework .
ALEX_CROME 21-Feb-15 11:05am    
The problem is XOR is not working (fitting well) in this frame. I want to use xor but somehow messing things up.
x = 0;
for(i=0 to N)
for (j = 0 to N)
x = table[i][j] ^ x ;
assert(x == true);

somehow not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900