/** Copyright (c) 2012, School of Computer Science, Yantai University * All Rights Reserved. * Author: Zhao guanzhe * Completion Date: July 15, October 8, 2012 * version number: V1.0 ** input Description: two positive integers * Problem description: Given two positive integers, calculate the positive difference between two numbers and output *ProgramOutput: Given the positive difference between two numbers * Problem Analysis: by comparing the two numbers, we can ensure that the value is reduced by the limit and the positive difference is obtained *AlgorithmDESIGN: omitted */# include <iostream> using namespace STD; int main () {int A, B, C, D, E; cout <"enter, value of B: "; CIN> A> B; If (A> B) {c = A; D = B;} else {c = B; D = A;} e = c-d; cout <"positive difference =" <e <"\ n"; return 0 ;}
Running result:
Experience:
After a while of thinking, he handed over the task to complete. After independent thinking and continuous debugging, no errors were displayed. This program can also be simpler and simpler. It is being modified .............
Knowledge Point summary;
When calculating the positive difference value, compare the size by programming, and reduce the value by a small margin. The result is an integer. Do not subtract the two numbers directly to avoid negative values.