Hi I'm writing a program that is designed to have a user input the degree and coefficients for a polynomial with two variables, x and y, and i'm having trouble figureing out how to output the degree for the y, and tryin to ignore the term if the coefficient is zero. Can anyone help me?

const int arraysize = 7;
void print ( int , int [][arraysize]);
int main()
{
      int power, input, array [arraysize][arraysize] = {0};

      cout << "What is the degree of your polynomial?"
           << "\nEnter a natural number less than 7: ";
      while ( cin >> power && power < 0 || power > 7 )
      {
            cout << "\nPick another number: ";
       }

      for ( int i = power; i >= 0; i--)
      {
          for ( int j = 0; j <= i; j++ )
          {
              cout << "\nEnter the coefficient for x^" << i - j << "y^" << j << " ";
              cin >> input;
              array [i][j] = input;
           }
       }
      print ( power, array );

      system("PAUSE");
      return 0;
}

void print ( int c, int buffer [][arraysize] )
{
     if ( c = 0 )
        cout << "";

    // cout << buffer [c][c] << "x^" << c << "y^" << c;

     for ( int i = c - 1; i >= 0; i-- )
     {
         if ( buffer [c][i] < 0 )
             cout << " - ";
         else
             cout << " + ";

         cout << buffer [c][i] << "x^" << c - i << "y^" << i;
     }
}

Recommended Answers

All 3 Replies

>Can anyone help me?
Sorry, I don't help people who spam as many forums as they can with their problem. You obviously don't trust the answers you'll get here, or you wouldn't have posted on other sites, so go there to get your help.

actually i was trying to see who i could get the answer from sooner thanks

>actually i was trying to see who i could get the answer from sooner thanks
The best programmers will visit and post to all of the popular forums. Posting on multiple sites hinders your chances of getting a good answer because it's insulting to those who are best suited to giving you the highest quality help. You're basically saying that you don't think the people on one site will be able to answer the question to your satisfaction, so you'll post to other sites as well until you find someone "smart" enough to make you happy.

I simply ignored you elsewhere, but now I'm telling you exactly how I see your little "getting an answer sooner" game. Don't expect my interpretation to be unique either.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.