Name five of the greatest books in human civilization
时间: 2024-06-04 21:11:27 浏览: 93
Sure, I can answer that. Five of the greatest books in human civilization are:
1. The Bible
2. The Quran
3. The Iliad and the Odyssey by Homer
4. The Divine Comedy by Dante Alighieri
5. Don Quixote by Miguel de Cervantes
相关问题
用c语言写4、 创建文件,写入内容,输出结果 1) 在D盘创建一个文件“I have a dream.txt”; 2) 在该文件内,写入以下内容: I have a dream Martin Luther King I am happy to join with you today in what will go down in history as the greatest demonstration for freedom in the history of our nation. Five score years ago, a great American, in whose symbolic shadow we stand today, signed the Emancipation Proclamation. This momentous decree came as a great beacon light of hope to millions of Negro slaves who had been seared in the flames of withering injustice. It came as a joyous daybreak to end the long night of their captivity. But one hundred years later, the Negro still is not free. 3) 打开该文件,将全部内容打印出来,关闭文件。
```c
#include <stdio.h>
int main() {
FILE *fp;
fp = fopen("D:\\I have a dream.txt", "w");
fprintf(fp, "I have a dream Martin Luther King I am happy to join with you today in what will go down in history as the greatest demonstration for freedom in the history of our nation. Five score years ago, a great American, in whose symbolic shadow we stand today, signed the Emancipation Proclamation. This momentous decree came as a great beacon light of hope to millions of Negro slaves who had been seared in the flames of withering injustice. It came as a joyous daybreak to end the long night of their captivity. But one hundred years later, the Negro still is not free.\n");
fclose(fp);
fp = fopen("D:\\I have a dream.txt", "r");
char ch;
while((ch = getc(fp)) != EOF) {
putchar(ch);
}
fclose(fp);
return 0;
}
```
运行结果:
```
I have a dream Martin Luther King I am happy to join with you today in what will go down in history as the greatest demonstration for freedom in the history of our nation. Five score years ago, a great American, in whose symbolic shadow we stand today, signed the Emancipation Proclamation. This momentous decree came as a great beacon light of hope to millions of Negro slaves who had been seared in the flames of withering injustice. It came as a joyous daybreak to end the long night of their captivity. But one hundred years later, the Negro still is not free.
```
Create a class called Rational for performing arithmetic with fractions. Use integer variables to represent the private data of the class – the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it’s declared. The constructor should store the fraction in reduced form. For example, the fraction 2/4 would be stored in the object as 1 in the numerator and 2 in the denominator. In order to compute the reduced form, you need to write a reduction function which uses the Euclidean algorithm to get the greatest common divisor (GCD) of the numerator and denominator first and then divides GCD to get the reduced numerator and denominator. Provide public member functions that perform each of the following tasks: (a) Subtract a Rational number from the other Rational number. The result should be stored in reduced form. (b) Divide a Rational number by the other Rational number. The result should be stored in reduced form. (c) Print Rational numbers in the form a/b, where a is the numerator and b is the denominator. (d)Compare two Rational numbers to make sure which one is smaller or they are equal. (1 for the first number, 2 for the second number and 0 if they are equal) Please also write a main function to prompt the user to input two Rational numbers . Subtract one number from the other from these two numbers using (a) and then print the result using (c). Divide one number from the other from these two numbers using (b) and then print the result using (c). Compare these two Rational numbers using (d) and indicate which one is smaller or they are equal. 用c++5.11寫出,且使用using namespace std;
以下是符合要求的C++ 代码:
```
#include <iostream>
using namespace std;
class Rational {
private:
int numerator, denominator;
int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
public:
Rational(int num = 0, int den = 1) {
int divisor = gcd(num, den);
numerator = num / divisor;
denominator = den / divisor;
}
Rational operator- (Rational other) {
int num = numerator * other.denominator - other.numerator * denominator;
int den = denominator * other.denominator;
return Rational(num, den);
}
Rational operator/ (Rational other) {
int num = numerator * other.denominator;
int den = denominator * other.numerator;
return Rational(num, den);
}
void print() {
cout << numerator << "/" << denominator;
}
int compare(Rational other) {
int num1 = numerator * other.denominator;
int num2 = other.numerator * denominator;
if (num1 < num2) return 1;
if (num1 > num2) return 2;
return 0;
}
};
int main() {
Rational r1, r2;
cout << "Enter the first rational number (numerator denominator): ";
cin >> r1;
cout << "Enter the second rational number (numerator denominator): ";
cin >> r2;
Rational diff = r1 - r2;
cout << "The difference is ";
diff.print();
cout << endl;
Rational quotient = r1 / r2;
cout << "The quotient is ";
quotient.print();
cout << endl;
int result = r1.compare(r2);
if (result == 1) {
cout << "The first number is smaller." << endl;
} else if (result == 2) {
cout << "The second number is smaller." << endl;
} else {
cout << "The two numbers are equal." << endl;
}
return 0;
}
```
请注意,此代码使用了重载运算符-和/来实现两个Rational数的减法和除法。此外,它还定义了一个比较函数来比较两个Rational数的大小。在主函数中,我们首先提示用户输入两个Rational数,然后执行所需的操作并输出结果。
阅读全文