Sunday, March 29, 2009

[Cpp-Programming] i need help in C++

Alright.. i kinda solved the question, but i cant solve the error.
please let me know if you can help.

-The question is:
Create the attached linked list using stuct nodes. Use the linked
list to print out as a polynomial... -3x^7 + 4x^5 + 7x^3 - x^2 + 9.

-If you would like to see a diagram for it go to:
http://bb.cos.edu/courses/1/09-S-CSCI002-22439/content/_286958_1/linked_list.pdf


Here is what i did.

#include <iostream>
#include <string>
using namespace std;


struct Node{
string coeff;
int power;
Node *nextPtr;
};
Node* inputPolynomial( void );
void deletePolynomial( Node * );
double evaluatePolynomial(Node *, double x);
void printPolynomial( Node * );


void addNodeAfter (Node *, string, int);


int main(void){

int size = 7;
Node *dhead = NULL;
Node *cur = NULL;

dhead = new Node();
cur = dhead;

cur ->coeff = "-3";
cur->power = 7;
cur->nextPtr = new Node();

cur = cur->nextPtr;

cur->coeff = "4x";
cur->power = 5;
cur->nextPtr = new Node();

cur = cur->nextPtr;

cur->coeff = "7";
cur->power = 3;
cur->nextPtr = new Node();

cur = cur->nextPtr;

cur->coeff = "-1";
cur->power = 2;
cur->nextPtr = new Node();

cur = cur->nextPtr;

addNodeAfter(dhead, "9" , 0);
printPolynomial(dhead);

return(0);
}

void printPolynomail(Node *passNode){
Node *tempCur = passNode;

while (tempCur->nextPtr != passNode){

cout << tempCur->coeff << endl;
tempCur = tempCur->nextPtr;
}
cout << tempCur->coeff << endl;

}

void deletePolynomial(Node *passNode){
passNode->nextPtr = (passNode->nextPtr)->nextPtr;
}

void addNodeAfter (Node*passNode, string coeff, int power){

Node *temp = passNode->nextPtr;

passNode->nextPtr = new Node();
(passNode->nextPtr)->coeff = coeff;
(passNode->nextPtr)->power = power;
(passNode->nextPtr)->nextPtr = temp;
//(passNode->nextPtr)->prevPtr = passNode;

//temp->prevPtr = passNode->nextPtr;


}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

Saturday, March 28, 2009

[Cpp-Programming] Earth Hour 2009 in IIT Roorkee.(Regarding Global Warming)





Climate Change is a real issue and the time has come to vote against it .

 

Earth Hour has been transformed into the world's first global election, between Earth and global warming.people of all ages, nationalities, race and background have the opportunity to use their light switch as their vote – Switching off your lights is a vote for Earth, or leaving them on is a vote for global warming. In 2009, India joins Earth Hour for the first time. New Delhi and Mumbai are among 825 cities across 80 countries and territories that have pledged their support to VOTE EARTH during Earth Hour 2009. 

 

Earth Hour 2009 is taking place in IIT Roorkee and it is a responsibility of all of us to make it a successWe all have a vote, and every single vote counts. Together we can take control of the future of our planet, for future generations.

 

VOTE EARTH by simply switching off your lights for one hour on Saturday, March 28, 8:30 pm to 9:30 pm local time. 

 

Please forward this message to your friends also .

 

SO VOTE against climate change tomorrow by switching off your lights . Also please campaign for the Earth Hour so that the message reaches everyone. 

 

 

For more details visit www.earthhour.in . 




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

Sunday, March 22, 2009

[Cpp-Programming] Re: help

Reep,
both programs are good except few statements..
 
First Program:
Here you defined row and column = 4 but your loop a<row-1 i.e. a<3 will execute only three times. I believe u are trying to add 4x4 matrix, so just change all the for loops condition to either a <= row-1 or a < row. If u want 3x3 matrix, then define row and column as 3 and make changes in all for loops as suggested above.
 
Second thing, remove the defination of c d e f g h, it is unneccassarily occupying the memory.
 
Second program:
Looks good but i am not sure about cin>>c>>d; will it ask for value once and assign it to both the variables i.e. c and d? I mostly worked on C, so never used cin/cout, sorry.
 
Let me know if u have any question.
 
~Atul

On Thu, Mar 12, 2009 at 8:56 PM, reepakmajhi.com@gmail.com <reepakmajhi.com@gmail.com> wrote:

is this 2 program code right of  two matrix addition



1st program



#include<iostream.h>
#define row 4
#define col 4

int main()
{
   int i[row][col],j[row][col],k[row][col];
   int a,b,c,d,e,f,g,h;

   for(a=0;a<row-1;a++)
 {  cout<<"\n";
       for(b=0;b<col-1;b++)
          cin>>i[a][b];
}
for(a=0;a<row-1;a++)
  { cout<<"\n";
       for(b=0;b<col-1;b++)
          cin>>j[a][b];
          }

 for(a=0;a<row-1;a++)
  { cout<<"\n";
       for(b=0;b<col-1;b++)
          k[a][b]= j[a][b]+i[a][b];  }


 for(a=0;a<row-1;a++)
   {cout<<"\n";
       for(b=0;b<col-1;b++)
         cout<<"\t";
          cout<<k[a][b];}

         system("pause"); }





2nd program




#include<iostream.h>


int main()
{
   int i[10][10],j[10][10],k[10][10];
   int a,b,c,d,e,f;
  cin>>c>>d;
     cin>>e>>f;
   for(a=0;a<c;a++)
 {  cout<<"\n";
       for(b=0;b<d;b++)
          cin>>i[a][b];
}
for(a=0;a<e;a++)
  { cout<<"\n";
       for(b=0;b<f;b++)
          cin>>j[a][b];
          }

 for(a=0;a<c;a++)
  { cout<<"\n";
       for(b=0;b<d;b++)
          k[a][b]= j[a][b]+i[a][b];  }


 for(a=0;a<c;a++)
   {cout<<"\n";
       for(b=0;b<d;b++)
         cout<<"\t";
          cout<<k[a][b];}

         system("pause"); }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

Thursday, March 12, 2009

[Cpp-Programming] Re: help

On Thu, Mar 12, 2009 at 11:26 AM, reepakmajhi.com@gmail.com <reepakmajhi.com@gmail.com> wrote:

is this 2 program code right of  two matrix addition



1st program



#include<iostream.h>
#define row 4
#define col 4

int main()
{
   int i[row][col],j[row][col],k[row][col];
   int a,b,c,d,e,f,g,h;

   for(a=0;a<row-1;a++)
 {  cout<<"\n";
       for(b=0;b<col-1;b++)
          cin>>i[a][b];
}
for(a=0;a<row-1;a++)
  { cout<<"\n";
       for(b=0;b<col-1;b++)
          cin>>j[a][b];
          }

 for(a=0;a<row-1;a++)
  { cout<<"\n";
       for(b=0;b<col-1;b++)
          k[a][b]= j[a][b]+i[a][b];  }


 for(a=0;a<row-1;a++)
   {cout<<"\n";
       for(b=0;b<col-1;b++)
         cout<<"\t";
          cout<<k[a][b];}

         system("pause"); }





2nd program




#include<iostream.h>


int main()
{
   int i[10][10],j[10][10],k[10][10];
   int a,b,c,d,e,f;
  cin>>c>>d;
     cin>>e>>f;
   for(a=0;a<c;a++)
 {  cout<<"\n";
       for(b=0;b<d;b++)
          cin>>i[a][b];
}
for(a=0;a<e;a++)
  { cout<<"\n";
       for(b=0;b<f;b++)
          cin>>j[a][b];
          }

 for(a=0;a<c;a++)
  { cout<<"\n";
       for(b=0;b<d;b++)
          k[a][b]= j[a][b]+i[a][b];  }


 for(a=0;a<c;a++)
   {cout<<"\n";
       for(b=0;b<d;b++)
         cout<<"\t";
          cout<<k[a][b];}

         system("pause"); }
 

Oh god my eyes they're bleeding

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

[Cpp-Programming] help

is this 2 program code right of two matrix addition

1st program

#include<iostream.h>
#define row 4
#define col 4

int main()
{
int i[row][col],j[row][col],k[row][col];
int a,b,c,d,e,f,g,h;

for(a=0;a<row-1;a++)
{ cout<<"\n";
for(b=0;b<col-1;b++)
cin>>i[a][b];
}
for(a=0;a<row-1;a++)
{ cout<<"\n";
for(b=0;b<col-1;b++)
cin>>j[a][b];
}

for(a=0;a<row-1;a++)
{ cout<<"\n";
for(b=0;b<col-1;b++)
k[a][b]= j[a][b]+i[a][b]; }


for(a=0;a<row-1;a++)
{cout<<"\n";
for(b=0;b<col-1;b++)
cout<<"\t";
cout<<k[a][b];}

system("pause"); }

2nd program


#include<iostream.h>


int main()
{
int i[10][10],j[10][10],k[10][10];
int a,b,c,d,e,f;
cin>>c>>d;
cin>>e>>f;
for(a=0;a<c;a++)
{ cout<<"\n";
for(b=0;b<d;b++)
cin>>i[a][b];
}
for(a=0;a<e;a++)
{ cout<<"\n";
for(b=0;b<f;b++)
cin>>j[a][b];
}

for(a=0;a<c;a++)
{ cout<<"\n";
for(b=0;b<d;b++)
k[a][b]= j[a][b]+i[a][b]; }


for(a=0;a<c;a++)
{cout<<"\n";
for(b=0;b<d;b++)
cout<<"\t";
cout<<k[a][b];}

system("pause"); }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

[Cpp-Programming] Re: Please Help Compiler

On Feb 28, 5:28 pm, Angel <m.of....@gmail.com> wrote:
>  Visual C++ Express Edition

CIDEE that i found
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

Wednesday, March 11, 2009

Your female needs more? It's easy! 78

Our pilules can make you a superman of bed-action fast and easy.

http://spreadsheets.google.com/viewform?formkey=cDFHeXJ4cFZVY3BqSWM0YklqNnI5U1E6Mv#Deborah



































































































02254

 
 

Sent to you by Eddy via Google Reader:

 
 

by Eddy on 3/11/09

1323

 
 

Things you can do from here: