Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   coding with link list (http://www.go4expert.com/forums/coding-link-list-t6770/)

ckmelissa86 10Oct2007 19:12

coding with link list
 
hi,i'm Melissa from Malaysia.. I'm a Uni student and i got problem with link list programming.Hope that you can help me to solve it

Well, now i need to write a program which using link list to make a calculator.

The concept which i plan to do is that.. 3 digit save in 1 node in reverse order.. then when we need to do some math operation like addition or subtraction.. the operation if execute in the reverse order..

Hope you guys will help me .. and hope i can get ur reply soon...

Take care and all the Best

Best regard:
Melissa

seeguna 15Oct2007 11:23

Re: coding with link list
 
Post ur trying code so that i will rectify ur problem

ckmelissa86 18Oct2007 16:27

Re: coding with link list
 
Code:

//libraries
#include<iostream.h>
#include<conio.h>

void main()
{ //declare the variables
    int i[3][10];
  char c[2][10];
  int bil;

//promt the user to enter the number
  cout<<"Masukkan bilangan digit : ";
  cin>>bil;

//loop for enter 2 difference number
  for(int y=0;y<2;y++)
  {
        //loop for enter the number 
      for (int x=bil-1;x>=0;x--)
      {
      cin>>c[y][x];
      }
  }

//loop for convert the 2 numbers into int
  for(int y=0;y<2;y++)
  {
      for (int x=bil-1;x>=0;x--)
      {
      i[y][x]=(int)c[y][x];
      }
  }

//Display result
    for(int y=0;y<2;y++)
  {
      for (int x=bil-1;x>=0;x--)
      {
      cout<<i[y][x]<<"  ";

      }  cout<<endl;
  }

 //this part not understand
int b=0;
      for (int x=bil-1;x>=0;x--)
      {
      i[2][x]=i[0][x]+i[1][x]+b;
      if(i[2][x]>10)
        {
          i[2][x]=i[2][x]-10;
          b=1;
          }
      else
          b=0;
      }

//Display result
      for (int x=0;x<bil;x++)
      {
      cout<<i[2][x]<<"  ";

      } 

  getch();
  }

this is the rough coding i did.. but this is only for addition..i am still trying to do for subtraction

Thx for helping

DaWei 18Oct2007 19:31

Re: coding with link list
 
Read the "Before you make a query" thread, particularly with regard to the use of code tags.

seeguna 19Oct2007 11:18

Re: coding with link list
 
hi,
I just go thru ur coding, What u did is "Read some characters in an array, Convert that character array as Integer array and finally u add the integers values present in it"....
i..e very basic program


Where is ur Linked list problem?
I think that u sent something else.....

If u clearly explain ur problem means i m ready to solve it..............


All times are GMT +5.5. The time now is 09:25.