Fejtsd meg az alábbi kódot! (Az elsőnek 5 kisbajnokság üti a markát, természetesen a megfejtésben használt saját C progijaiért.)
00000010101010000000000001010000010100000001001000100010001001011001010101010101010100100100000000000000000000000000000000000001100000000000000000001101000000000000000000011010000000000000000001010100000000000000000011111000000000000000000000000000000001100001110001100001100010000000000000110010000110100011000110000110101111101111101111101111100000000000000000000000000100000000000000000100000000000000000000000000001000000000000000001111110000000000000111110000000000000000000000011000011000011100011000100000001000000000100001101000011000111001101011111011111011111011111000000000000000000000000001000000110000000001000000000001100000000000000010000011000000000011111100000110000001111100000000001100000000000001000000001000000001000001000000110000000100000001100001100000010000000000110001000011000000000000000110011000000000000011000100001100000000011000011000000100000001000000100000000100000100000001100000000100010000000011000000001000100000000010000000100000100000001000000010000000100000000000011000000000110000000011000000000100011101011000000000001000000010000000000000010000011111000000000000100001011101001011011000000100111001001111111011100001110000011011100000000010100000111011001000000101000001111110010000001010000011000000100000110110000000000000000000000000000000000011100000100000000000000111010100010101010101001110000000001010101000000000000000010100000000000000111110000000000000000111111111000000000000111000000011100000000011000000000001100000001101000000000101100000110011000000011001100001000101000001010001000010001001000100100010000000010001010001000000000000100001000010000000000001000000000100000000000000100101000000000001111001111101001111000
4 nap múlva...
Íme a megoldást mutató program, s itt olvashatsz magáról a nagyon híres és ismert üzenetről.
Tekerja tovább linkre a forrásért:
main.cpp
#include <QtGui/QApplication> #include "areciboablak.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); AreciboAblak w(23, 73, "00000010101010000000000001010000010100000001001000100010001001011001010101010101010100100100000000000000000000000000000000000001100000000000000000001101000000000000000000011010000000000000000001010100000000000000000011111000000000000000000000000000000001100001110001100001100010000000000000110010000110100011000110000110101111101111101111101111100000000000000000000000000100000000000000000100000000000000000000000000001000000000000000001111110000000000000111110000000000000000000000011000011000011100011000100000001000000000100001101000011000111001101011111011111011111011111000000000000000000000000001000000110000000001000000000001100000000000000010000011000000000011111100000110000001111100000000001100000000000001000000001000000001000001000000110000000100000001100001100000010000000000110001000011000000000000000110011000000000000011000100001100000000011000011000000100000001000000100000000100000100000001100000000100010000000011000000001000100000000010000000100000100000001000000010000000100000000000011000000000110000000011000000000100011101011000000000001000000010000000000000010000011111000000000000100001011101001011011000000100111001001111111011100001110000011011100000000010100000111011001000000101000001111110010000001010000011000000100000110110000000000000000000000000000000000011100000100000000000000111010100010101010101001110000000001010101000000000000000010100000000000000111110000000000000000111111111000000000000111000000011100000000011000000000001100000001101000000000101100000110011000000011001100001000101000001010001000010001001000100100010000000010001010001000000000000100001000010000000000001000000000100000000000000100101000000000001111001111101001111000"); w.show(); return a.exec(); }
areciboablak.h
#ifndef ARECIBOABLAK_H #define ARECIBOABLAK_H #include <QtGui/QMainWindow> #include <QPainter> #include <string> #include <iostream> class AreciboAblak : public QMainWindow { Q_OBJECT public: AreciboAblak(int szelesseg = 23, int magassag = 73, std::string uzenet = "00000010101010000000000001010000010100000001001000100010001001011001010101010101010100100100000000000000000000000000000000000001100000000000000000001101000000000000000000011010000000000000000001010100000000000000000011111000000000000000000000000000000001100001110001100001100010000000000000110010000110100011000110000110101111101111101111101111100000000000000000000000000100000000000000000100000000000000000000000000001000000000000000001111110000000000000111110000000000000000000000011000011000011100011000100000001000000000100001101000011000111001101011111011111011111011111000000000000000000000000001000000110000000001000000000001100000000000000010000011000000000011111100000110000001111100000000001100000000000001000000001000000001000001000000110000000100000001100001100000010000000000110001000011000000000000000110011000000000000011000100001100000000011000011000000100000001000000100000000100000100000001100000000100010000000011000000001000100000000010000000100000100000001000000010000000100000000000011000000000110000000011000000000100011101011000000000001000000010000000000000010000011111000000000000100001011101001011011000000100111001001111111011100001110000011011100000000010100000111011001000000101000001111110010000001010000011000000100000110110000000000000000000000000000000000011100000100000000000000111010100010101010101001110000000001010101000000000000000010100000000000000111110000000000000000111111111000000000000111000000011100000000011000000000001100000001101000000000101100000110011000000011001100001000101000001010001000010001001000100100010000000010001010001000000000000100001000010000000000001000000000100000000000000100101000000000001111001111101001111000", QWidget *parent = 0); ~AreciboAblak(); std::string uzenet; protected: int cellaSzelesseg; int cellaMagassag; int szelesseg; int magassag; void paintEvent(QPaintEvent*); }; #endif // ARECIBOABLAK_H
areciboablak.cpp
#include "areciboablak.h" AreciboAblak::AreciboAblak(int szelesseg, int magassag, std::string uzenet, QWidget *parent) : QMainWindow(parent) { setWindowTitle("Az arecibói üzenet"); this->magassag = magassag; this->szelesseg = szelesseg; this->uzenet = uzenet; // ha az üzenet hossza != m*sz, akkor zavar lesz az erőben cellaSzelesseg = 6; cellaMagassag = 6; setFixedSize(QSize(szelesseg*cellaSzelesseg, magassag*cellaMagassag)); } void AreciboAblak::paintEvent(QPaintEvent*) { QPainter qpainter(this); for(int i=0; i<magassag; ++i) { for(int j=0; j<szelesseg; ++j) { if(uzenet.at(i*szelesseg+j) == '1') qpainter.fillRect(j*cellaSzelesseg, i*cellaMagassag, cellaSzelesseg, cellaMagassag, Qt::black); else qpainter.fillRect(j*cellaSzelesseg, i*cellaMagassag, cellaSzelesseg, cellaMagassag, Qt::white); qpainter.setPen(QPen(Qt::gray, 1)); qpainter.drawRect(j*cellaSzelesseg, i*cellaMagassag, cellaSzelesseg, cellaMagassag); } } qpainter.end(); } AreciboAblak::~AreciboAblak() { }