Г. Схема алгоритма
НАЧАЛО КОНЕЦ Ввод
A, B, D (signed int) Ввод
A, B, D (unsigned int) Ввод
A, B, D (signed char) Ввод
A, B, D (unsigned char) Вывод
числителя, знаменателя, результата
(signed
int) Вывод
числителя, знаменателя, результата
(unsigned
int) Вывод
числителя, знаменателя, результата
(signed
char) Вывод
числителя, знаменателя, результата
(unsigned
char) Вычисление
C++ Вычисление
ASM
Д. Таблица результатов
Результаты вычислений приведены ниже в таблице вычислений.
Тип |
A |
B |
D |
Числитель |
Знаменатель |
Результат |
Signed Byte |
1 |
1 |
99 |
С++: 102 ASM: 102 |
34 34 |
3 3 |
-1 |
-1 |
-99 |
С++: -102 ASM: -102 |
-32 -32 |
3 3 |
|
-10000 |
1 |
10005 |
С++: 48 ASM: 48 |
51 51 |
0 0 |
|
Unsigned Byte |
1 |
1 |
99 |
С++: 102 ASM: 102 |
34 34 |
3 3 |
2 |
1 |
105 |
С++: 162 ASM: 162 |
33 33 |
4 4 |
|
2 |
1 |
10005 |
С++: 65530 ASM: 65530 |
33 33 |
1985 1985 |
|
Signed Word |
1 |
1 |
99 |
С++: 102 ASM: 102 |
34 34 |
3 3 |
-1 |
-1 |
-99 |
С++: -102 ASM: -102 |
-32 -32 |
3 3 |
|
-10000 |
1 |
10005 |
С++: 20010 ASM: 20010 |
10035 10035 |
1 1 |
|
Unsigned Word |
1 |
1 |
99 |
С++: 102 ASM: 102 |
34 34 |
3 3 |
2 |
1 |
105 |
С++: 162 ASM: 162 |
33 33 |
4 4 |
|
2 |
1 |
10005 |
С++: 19962 ASM: 19962 |
33 33 |
604 604 |
Е. Программа /* Файл cpp */
/// (2 * d - 96 / a) / (34 / b - a + 1)
/// IDE: BORLAND C++ 3.1
#include <iostream.h>
/// SIGNED INT-16 (16 BITS)
signed int Si_A, Si_B, Si_D, SiDenominator;
signed long SiNumerator, SiResult;
/// UNSIGNED INT-16 (16 BITS)
unsigned int Ui_A, Ui_B, Ui_D, UiDenominator;
unsigned long UiNumerator, UiResult;
/// SIGNED INT-8 (8 BITS)
signed char Sc_A, Sc_B, Sc_D, ScDenominator;
signed int ScNumerator, ScResult;
/// UNSIGNED INT-8 (8 BITS)
unsigned char Uc_A, Uc_B, Uc_D, UcDenominator;
unsigned int UcNumerator, UcResult;
extern "C" { void LabSi(); void LabUi(); void LabSc(); void LabUc();}
/// SIGNED INT-16 (16 BITS)
/// Signed Int C
void SiC() {
SiNumerator = 2 * Si_D - 96 / Si_A; /// Числитель
SiDenominator = 34 / Si_B - Si_A + 1; /// Знаменатель
SiResult = SiNumerator / SiDenominator; /// Результат
cout << "Si, C++: Numerator: " << SiNumerator << ", Denominator: " << SiDenominator << endl;
cout << "Si, C++: Result = " << SiResult << endl;
}
/// Signed Int ASM
void SiASM() {
SiNumerator = 0; SiDenominator = 0; SiResult = 0;
LabSi();
cout << "Si, ASM: Numerator: " << SiNumerator << ", Denominator: " << SiDenominator << endl;
cout << "Si, ASM: Result = " << SiResult << endl;
}
/// UNSIGNED INT-16 (16 BITS)
/// Unsigned Int C
void UiC() {
UiNumerator = 2 * Ui_D - 96 / Ui_A; /// Числитель
UiDenominator = 34 / Ui_B - Ui_A + 1; /// Знаменатель
UiResult = UiNumerator / UiDenominator; /// Результат
cout << "Ui, C++: Numerator: " << UiNumerator << ", Denominator: " << UiDenominator << endl;
cout << "Ui, C++: Result = " << UiResult << endl;
}
/// Unsigned Int ASM
void UiASM() {
UiNumerator = 0; UiDenominator = 0; UiResult = 0;
LabUi();
cout << "Ui, ASM: Numerator: " << UiNumerator << ", Denominator: " << UiDenominator << endl;
cout << "Ui, ASM: Result = " << UiResult << endl;
}
/// SIGNED INT-8 (8 BITS)
/// Signed Char C
void ScC() {
ScNumerator = 2 * Sc_D - 96 / Sc_A; /// Числитель
ScDenominator = 34 / Sc_B - Sc_A + 1; /// Знаменатель
ScResult = ScNumerator / ScDenominator; /// Результат
cout << "Sc, C++: Numerator: " << ScNumerator << ", Denominator: " << ScDenominator << " (" << (int)ScDenominator << ")" << endl;
cout << "Sc, C++: Result = " << ScResult << endl;
}
/// Signed Char ASM
void ScASM() {
ScNumerator = 0; ScDenominator = 0; ScResult = 0;
LabSc();
cout << "Sc, ASM: Numerator: " << ScNumerator << ", Denominator: " << ScDenominator << " (" << (int)ScDenominator << ")" << endl;
cout << "Sc, ASM: Result = " << ScResult << endl;
}
/// UNSIGNED INT-8 (8 BITS)
/// Unsigned Char C
void UcC() {
UcNumerator = 2 * Uc_D - 96 / Uc_A; /// Числитель
UcDenominator = 34 / Uc_B - Uc_A + 1; /// Знаменатель
UcResult = UcNumerator / UcDenominator; /// Результат
cout << "Uc, C++: Numerator: " << UcNumerator << ", Denominator: " << UcDenominator << " (" << (unsigned int)UcDenominator << ")" << endl;
cout << "Uc, C++: Result = " << UcResult << endl;
}
/// Unsigned Char ASM
void UcASM() {
UcNumerator = 0; UcDenominator = 0; UcResult = 0;
LabUc();
cout << "Uc, ASM: Numerator: " << UcNumerator << ", Denominator: " << UcDenominator << " (" << (unsigned int)UcDenominator << ")" << endl;
cout << "Uc, ASM: Result = " << UcResult << endl;
}
/// MAIN FUNCTION
int main() {
int t;
cout << "SIGNED INT-16" << endl;
cout << "Signed int A: "; cin >> Si_A;
cout << "Signed int B: "; cin >> Si_B;
cout << "Signed int D: "; cin >> Si_D;
cout << "UNSIGNED INT-16" << endl;
cout << "Unsigned int A: "; cin >> Ui_A;
cout << "Unsigned int B: "; cin >> Ui_B;
cout << "Unsigned int D: "; cin >> Ui_D;
cout << "SIGNED INT-8" << endl;
cout << "Signed byte A: "; cin >> t; Sc_A = t;
cout << "Signed byte B: "; cin >> t; Sc_B = t;
cout << "Signed byte D: "; cin >> t; Sc_D = t;
cout << "UNSIGNED INT-8" << endl;
cout << "Unsigned byte A: "; cin >> t; Uc_A = t;
cout << "Unsigned byte B: "; cin >> t; Uc_B = t;
cout << "Unsigned byte D: "; cin >> t; Uc_D = t;
SiC(); SiASM();
UiC(); UiASM();
ScC(); ScASM();
UcC(); UcASM();
return 0;
}