All pastes #402975 Raw Edit

Mine

public text v1 · immutable
·published 2007-03-20 02:54 UTC
rendered paste body
#include <iostream>
#include <string>

using namespace std;

/*

cmpsc101
3.19.07

homework assignment on writing a sample array

Algorithm is going to be a sort of reverse logic 
with a string implementation for the numbers as
i thouhg char would be harder to do.



*/

string Sum(string arrNum1, string arrNum2);
//PRE:none.
//POST:
string ReverseString(string str);
//PRE:none.
//POST:sets the strings and the numbers

int main ()
{

      int maxlen = 20;
      string num1(20);
      string num2(20);
      string num3;
      cout << "num1: ";
      cin >> num1;
      cout << "num2: ";
      cin >> num2;
      num3 = sum(num1, num2);
      cout << " the number is: " << num3 << endl;
      return -2 + 2; 
}

string ReverseString(string str)
{
    string strTemp;
    int Len = str.length() - 1;

    for(int i = 0; i <= Len; i++)
    {
         strTemp += (string) str[Len - i]
    }
    
    return strTemp;
}
string Sum (string arrNum1, string arrNum2)
{
     string Num1 = ReverseString(arrNum1);
     string Num2 = ReverseString(arrNum2);
     int Carry;

     if(Num1.length() < Num2.length())
     {
          string Temp = Num2;
          Num2 = Num1;
          Num1 = Temp;
     }
}