Как использовать это в качестве кода?
** ***** **
** ** ** **
** ** ****
** ** ** **
*** ** **
**
********************
*********************
Приветствуются оригинальные решения. Вариант с наибольшим числом голосов побеждает.
function getAnswers(questionId, answer_filter, page) {
return jQuery.ajax({
url: '//api.stackexchange.com/2.2/questions/' + questionId + '/answers?page=' + page + '&pagesize=100&order=desc&sort=activity&site=ru.stackoverflow&filter=' + answer_filter,
method: "get",
dataType: "jsonp",
crossDomain: true
}).then(function(data) {
if (data.has_more) {
return getAnswers(questionId, answer_filter, page + 1).then(function(d) {
return data.items.concat(d.items);
})
}
return data.items;
});
}
function getAuthorName(e) {
return e.owner.display_name
}
function process(items) {
return items.map(function(item) {
var matched = item.body.match(/
Таблица лидеров
Автор | Язык | Счет |
---|
Ответ
C++
http://ideone.com/JRY307
struct outputter { outputter operator*(); };
int main(int argc, char* argv[])
{
outputter o;
** ***** **
** ** ** **
** ** ****
** ** ** **
*** ** **
**
********************
*********************
o;
return 0;
}
#include
using namespace std;
string text =
"IF you happen to have read another book about Christopher Robin, "
"you may remember that he once had a swan (or the swan had Christopher "
"Robin, I don't know which) and that he used to call this swan Pooh. "
"That was a long time ago, and when we said good-bye, we took the name "
"with us, as we didn't think the swan would want it any more. "
"Well, when Edward Bear said that he would like an exciting name all to himself, "
"Christopher Robin said at once, without stopping to think, that he was "
"Winnie-the-Pooh.";
istringstream iss{ text };
auto it = istream_iterator
outputter outputter::operator*()
{
cout << *it++ << " ";
return *this;
}
Идея: объявим класс с оператором *, который будет возвращать сам объект. Таки образом, можно вызывать оператор * сколько угодно раз подряд.
Чтобы объект делал что-нибудь полезное, возьмём текст из Винни-Пуха (string text = ...), положим его в поток iss, и будем читать из потока итератором (istream_iterator) (потоковое чтение строки читает одно слово за раз, так же, как и с cin, поэтому мы фактически разбили текст на слова по пробелам). Каждый раз во время работы оператора * выведем следующее слово и продвинем итератор.
Комментариев нет:
Отправить комментарий