Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7685885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:21:08+00:00 2026-05-31T19:21:08+00:00

NOTE: I had two variables with the same name… Big thanks to Stefan Birladeanu

  • 0

NOTE: I had two variables with the same name… Big thanks to Stefan Birladeanu and Henrik for noticing that!*

Recently I started writing code that helps me input the values of bool function to Veitch (Karnaugh) diagram with 4 variables. The code should write elements to matrix size 4×4 but with these indexes:

  1. element – index 3,3
  2. element – index 2,3
  3. element – index 3,2
  4. element – index 2,2
  5. element – index 0,3
  6. element – index 1,3
  7. element – index 0,2
  8. element – index 1,2
  9. element – index 3,0
  10. element – index 2,0
  11. element – index 3,1
  12. element – index 2,1
  13. element – index 0,0
  14. element – index 1,0
  15. element – index 0,1
  16. element – index 1,1
    This is the code of main():

        void main()
        {
            int n;
    
        n=4;
    
        int **VeitchDiagram;
    
        //allocate memory for Veitch diagram
        VeitchDiagram = new int *[n];
        for(int i=0; i<n; i++)
            VeitchDiagram[i]=new int [n];
    
        //enter the elements
        for(int i=0; i<n; i++)
        {
            int j, k;
            if(i%2==1)
            {
                k=0;
                if(i<2)
                    j=4;
                else
                    j=-1;
                for(int k=0; k<2; k++)
                {
                    if(i<2)
                        j--;
                    else
                        j++;
                    cin >> VeitchDiagram[k][j];     //this part writes the input to elements with index (at least it should do that):
                    k++;                            //0,3     1,3     0,2     1,2     if i%2==1 and i<2
                    cin >> VeitchDiagram[k][j];     //0,0     1,0     0,1     1,1     if i%2==1 and i>=2
                    k--;
                }
            }
            else
            {
                k=3;
                if(i<2)
                    j=4;
                else
                    j=-1;
                for(int k=0; k<2; k++)
                {
                    if(i<2)
                        j--;
                    else
                        j++;
                    cin >> VeitchDiagram[k][j];     //this part writes the input to elements with index (at least it should do that):
                    k--;                            //3,3     2,3     3,2     2,2    if i%2==0 and i<2
                    cin >> VeitchDiagram[k][j];     //3,0     2,0     3,1     2,1    if i%2==0 and i>=2
                    k++;
                }
            }
        }
    
        //free memory allocated for VeitchDiagram
        for(int i=0; i<n; i++)
            delete [] VeitchDiagram[i];
        delete [] VeitchDiagram;
    }
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:21:09+00:00Added an answer on May 31, 2026 at 7:21 pm
            for(int k=0; k<2; k++)
            {
                if(i<2)
                    j--;
                else
                    j++;
                cin >> VeitchDiagram[k][j];     //this part writes the input to elements with index (at least it should do that):
                k--;                            //3,3     2,3     3,2     2,2    if i%2==0 and i<2
                cin >> VeitchDiagram[k][j];     //3,0     2,0     3,1     2,1    if i%2==0 and i>=2
                                     ^ k == -1
    

    But you really should learn how to use a debugger.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two DPs that I update in a DefiningGeometry get: protected override Geometry
I had some help and some suggestions on how to remove a class name.
If I had two divs, both with id="myDiv", would $("#myDiv").fadeOut(); fade both divs out?
I have a table like this : (note that id_pack is not auto incremented)
I have recently been put in charge of debugging two different programs which will
Problem: a table of coordinate lat/lngs. Two rows can potentially have the same coordinate.
I have a C++ application that had a one time assertion failure that I
I'm trying to achieve two-way binding between a DataGridView and a BindingList that provides
I have two nib files, one that will open at startup and another that
I've opened up an ExtJs project that I've not had my head in for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.