请帮助找到错误

时间:2015-02-19 12:07:03

标签: c++ netbeans

我在NetBeans上做了一个程序,但是我有一个错误,我不知道该怎么做。 如果你们中的任何人能够帮助我,那就太棒了。

以下是我需要回答的问题:

尽可能干净地编写一个C ++程序:

1)声明一个数组classique1 t1字符串("到C")包含 一周中的日期名称(星期一,星期二......)

2)从t1,t2建立一个包含名称的新经典表 一周中的几天,但按升序字母顺序排序

3)以每行一天的名称,表t1和t2的内容

的比率显示

4)删除表t2

5)结束

在这个链接中:http://www.codeshare.io/wGWlQ是我做的程序。

1 个答案:

答案 0 :(得分:1)

尽可能干净利落的C ++程序":

std::array<std::string, 7> t1 = { // Array of strings t1
   "Monday", "Tuesday", "Wednesday", "Thursday",
   "Friday", "Saturday", "Sunday"
};

auto t2 = t1; // Create t2
std::sort(std::begin(t2), std::end(t2)); // to sort the right order

std::cout << "t1 content: " << std::endl; // Display contents
for (const auto& x : t1) {
   std::cout << x << std::endl;
}

std::cout << "t2 content: " << std::endl; // Display contents
for (const auto& x : t2) {
   std::cout << x << std::endl;
}

// Remove the table t2
// Ends

如果你真的必须使用c-strings,你可以将数组的类型改为const char*

相关问题