# C++代写 | C++ Implementation of Integer Addition, Multiplication, and Division

### C++代写 | C++ Implementation of Integer Addition, Multiplication, and Division

1 Task Description

You are asked to use C++ to implement

• School Method for Integer Addition and Karatsuba Algorithm for Integer Multiplication

• Integer Division (postgraduate only)

If you are an undergraduate student, the maximum mark (on Websubmission) is 100. If you are a postgraduate student, your maximum mark is 200.

2 Submission Guideline

You must follow this guideline! Your submission will be marked automatically. Failure to follow this guideline will result in 0.

Your submission should contain exactly one ﬁle: main.cpp. You do not need to submit a design.

Your program takes one line as input. The input line contains three integers separated by spaces. Let the three integers be I1, I2, and B. I1 and I2 are both nonnegative integers up to 100 digits long (there are no leading 0s, except when the value itself is 0). B is I1 and I2’s base (B is from 2 to 10).1

Your program should output the sum of I1 and I2, using the school method, then the product of I1 and I2, using the Karatsuba algorithm, and ﬁnally the ratio between I1 and I2 (rounded down). You are asked to come up with a way to perform this division. It’s not covered in lectures. I2 will not be 0. The results should still use base B. Please separate the results using one space.

Sample input 1: 101 5 10

Sample output 1: 106 505 20

Sample input 2: 10 111 2

Sample output 2: 1001 1110 0

Sample input 3: 111 10 2

Sample output 2: 1001 1110 11

If you are an undergraduate student, simply output 0 as the division result. For sample 3, instead of 1001 1110 11, simply output 1001 1110 0

3 Marking

Marking will be done automatically. I trust that you’d indeed implement the school method for addition and the Karatsuba algorithm for multiplication. If you use other methods in your submission, it will be considered cheating and you will receive 0. Feel free to use whatever method for division.

1This makes your life easier as you do not have to deal with numbers like ‘aﬀ4 Websubmission

You are asked to submit via the web interface https://cs.adelaide.edu.au/services/websubmission/. The submission steps should be self-explanatory. Simply choose the correct semester, course, and assignment. The websubmission system will automatically fetch the latest version of your work from your SVN repository (you may also choose to submit older versions). Once your work is submitted, the system will launch a script checking the format of your submission. Click “View Feedback” to view the results. Your mark will be calculated oﬄine after the deadline. You are welcome to resubmit for as many times as you wish (before the deadline).

We will compile your code using g++ -o main.out -O2 -Wall main.cpp. It is your responsibility to ensure that your code compiles on the university system.2