以下是一个C++程序,可以接受一行文本作为输入,并将该行文本以相反的顺序输出:
#include
#include
#include
int main() {
// 从标准输入中读取一行文本
std::string text;
std::getline(std::cin, text);
// 将文本进行反转
std::reverse(text.begin(), text.end());
// 输出反转后的文本
std::cout << text << std::endl;
return 0;
}
上述代码使用了C++的标准库函数std::reverse
来反转文本字符串,并使用std::cout
来输出结果。