on master help sign in
Add Cpp file test
commitb623adc6df59848c0cfd530332f69fa6bcb16a4e authorMithil Poojary <mithil467@gmail.com> dateMon 5 Oct 2020, 05:10 (6 years ago) parent2f77da7
2 files changed+158
tests/syntax-tests/highlighted/Cpp/test.cpp+79 tests/syntax-tests/source/Cpp/test.cpp+79
tests/syntax-tests/highlighted/Cpp/test.cppnew file+79
@@ -0,0 +1,79 @@
1+#include <bits/stdc++.h> // includes most of the useful libraries
2+#include "mainwindow.h"
3+
4+using namespace std;
5+
6+/* This C program was submitted to help bat
7+ * with its syntax highlighting tests
8+ */
9+
10+bool test_function(int x, int y)
11+{
12+ return (x == y || x + y == x * y);
13+}
14+
15+MainWindow::MainWindow(QWidget *parent)
16+ : QMainWindow(parent), ui(new Ui::MainWindow)
17+{
18+ ui->setupUi(this);
19+ resize(560, 420);
20+ // Image menu
21+ connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::open);
22+ MainWindow::~MainWindow()
23+ {
24+ delete ui;
25+ }
26+ int y = ui->graphicsView->size().height() - image.height();
27+ int x = ui->graphicsView->size().width() - image.width();
28+
29+ void MainWindow::showImage()
30+ {
31+ // Reset scale
32+ ui->graphicsView->resetMatrix();
33+
34+ statusBar()->showMessage(QString("%1 %2x%3px %4 kB").arg(file.fileName()).arg(image.width()).arg(image.height()).arg(QFile(currentFile).size() / 1000.0));
35+ }
36+}
37+
38+int main()
39+{
40+ int tc;
41+ cin >> tc;
42+ while (tc--) // for each test case
43+ {
44+ int n;
45+ cin >> n; // take n
46+ vector<pair<int, string>> v;
47+
48+ int a[n], b[n];
49+
50+ for (int i = 0; i < n; i++)
51+ cin >> a[i]; // take arrays
52+ for (int i = 0; i < n; i++)
53+ cin >> b[i];
54+
55+ priority_queue<int> pq; // inbuilt data structure - max heap (available in the bits/stdc++)
56+
57+ for (int i = 0; i < n; i++)
58+ pq.push(a[i]); // push elements into heap
59+
60+ for (int i = 0; i < n; i++) // for each element in B
61+ {
62+ int top_ele = pq.top(); // max element in heap
63+ pq.pop(); // deletion
64+ pq.push(top_ele ^ b[i]); // push after operation
65+ }
66+
67+ for (int i = n - 1; i >= 0; i--) // restore A in ascending order
68+ {
69+ a[i] = pq.top();
70+ pq.pop();
71+ }
72+
73+ for (int i = 0; i < n; i++)
74+ cout << a[i] << " "; // print A
75+
76+ cout << endl;
77+ }
78+ return 0;
79+}
tests/syntax-tests/source/Cpp/test.cppnew file+79
@@ -0,0 +1,79 @@
1+#include <bits/stdc++.h> // includes most of the useful libraries
2+#include "mainwindow.h"
3+
4+using namespace std;
5+
6+/* This C program was submitted to help bat
7+ * with its syntax highlighting tests
8+ */
9+
10+bool test_function(int x, int y)
11+{
12+ return (x == y || x + y == x * y);
13+}
14+
15+MainWindow::MainWindow(QWidget *parent)
16+ : QMainWindow(parent), ui(new Ui::MainWindow)
17+{
18+ ui->setupUi(this);
19+ resize(560, 420);
20+ // Image menu
21+ connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::open);
22+ MainWindow::~MainWindow()
23+ {
24+ delete ui;
25+ }
26+ int y = ui->graphicsView->size().height() - image.height();
27+ int x = ui->graphicsView->size().width() - image.width();
28+
29+ void MainWindow::showImage()
30+ {
31+ // Reset scale
32+ ui->graphicsView->resetMatrix();
33+
34+ statusBar()->showMessage(QString("%1 %2x%3px %4 kB").arg(file.fileName()).arg(image.width()).arg(image.height()).arg(QFile(currentFile).size() / 1000.0));
35+ }
36+}
37+
38+int main()
39+{
40+ int tc;
41+ cin >> tc;
42+ while (tc--) // for each test case
43+ {
44+ int n;
45+ cin >> n; // take n
46+ vector<pair<int, string>> v;
47+
48+ int a[n], b[n];
49+
50+ for (int i = 0; i < n; i++)
51+ cin >> a[i]; // take arrays
52+ for (int i = 0; i < n; i++)
53+ cin >> b[i];
54+
55+ priority_queue<int> pq; // inbuilt data structure - max heap (available in the bits/stdc++)
56+
57+ for (int i = 0; i < n; i++)
58+ pq.push(a[i]); // push elements into heap
59+
60+ for (int i = 0; i < n; i++) // for each element in B
61+ {
62+ int top_ele = pq.top(); // max element in heap
63+ pq.pop(); // deletion
64+ pq.push(top_ele ^ b[i]); // push after operation
65+ }
66+
67+ for (int i = n - 1; i >= 0; i--) // restore A in ascending order
68+ {
69+ a[i] = pq.top();
70+ pq.pop();
71+ }
72+
73+ for (int i = 0; i < n; i++)
74+ cout << a[i] << " "; // print A
75+
76+ cout << endl;
77+ }
78+ return 0;
79+}