int getline(char line[], int maxline);
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
vector<wstring> words = { L"1", L"Goose", L"14", L"gas", L"/" , L"file10", L"file11" };
sort(words.begin(), words.end());
for(auto s : words)
{
wcout << s << " ";
}
wcout << endl;
wcin.get();
}
OUT: / 1 14 Goose file10 file11 gas
bool find(node* n, int value)
{
node* ptr = n;
while(ptr != nullptr)
{
if(ptr->value == value) return true;
ptr = ptr->next;
}
return false;
}
node* find(node* n, int value)
{
node* ptr = n;
while(ptr != nullptr)
{
if(ptr->value == value) return ptr;
ptr = ptr->next;
}
return ptr;
}
node* result = find(...);
if(result)
{
//...
}
What are the supported operating systems?
C:\Users\Angi\Desktop\DemoGame\x64\Debug\DemoGame.exe
var sqlite = require('sqlite-sync');
sqlite.connect(':memory:');
sqlite.run("CREATE TABLE TableName(Id INTEGER PRIMARY KEY, Key INTEGER NOT NULL)");
sqlite.run("INSERT INTO TableName VALUES(1, 892)");
var result = sqlite.run("SELECT Key FROM TableName WHERE Id = 1");
console.log(result[0].Key);
OUT: 892
#include <stdio.h>
#include <stdlib.h>
void swap(int* a, int* b)
{
int c = *a;
*a = *b;
*b = c;
}
void reverse(int* first, int* last)
{
while((first != last) && (first != --last))
{
swap(first++, last);
}
}
int* reverse_copy(int* first, int size)
{
int* result = (int*)malloc(size * sizeof(int));
for(int i = 0; i < size; ++i)
{
result[i] = first[size - i - 1];
}
return result;
}
int main()
{
int a[] = {0,1,2,3,4,5,6,7,8,9};
reverse(a, &a[10]);
for(int i = 0; i < 10; ++i)
{
printf("%d ", a[i]);
}
printf("\n");
int* b = reverse_copy(a, 10);
for(int i = 0; i < 10; ++i)
{
printf("%d ", b[i]);
}
free(b);
}
OUT:
9 8 7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7 8 9
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "memdb");
db.setDatabaseName(":memory:");
if (!db.open())
{
qDebug() << db.lastError().text();
// std::exit(1);
}
QSqlQuery q("", db);
q.exec("create table Universities (id integer primary key, Location varchar, Population integer)");
q.exec("insert into Universities values (0, 'MSK', 12000000)");
q.exec("insert into Universities values (1, 'NSK', 1600000)");
q.exec("insert into Universities values (2, 'SPB', 6000000)");
q.exec("insert into Universities values (3, 'PRM', 1000000)");
int sz = ui->tableWidget->rowCount();
QString queryString = "SELECT * FROM Universities WHERE Location IN (";
for(int i = 0; i < sz; ++i)
{
queryString += "?,";
}
queryString.back() = ')';
QSqlQuery query(queryString, db);
for(int i = 0; i < sz; ++i)
{
query.bindValue(i, ui->tableWidget->item(i, 0)->text());
}
if (!query.exec())
{
qDebug() << query.lastError().text();
// std::exit(1);
}
while(query.next())
{
qDebug() << query.value(0).toInt() << " "
<< query.value(1).toString() << " "
<< query.value(2).toInt() << "\n";
}
QSqlQuery query;
query.prepare("SELECT * FROM Universities WHERE Location IN (?)");
int sz = ui->tableWidget->rowCount();
QVariantList values;
for(int i = 0; i < sz; ++i)
{
values << ui->tableWidget->item(i, 0)->text();
}
query.addBindValue(values);
if (!query.execBatch())
{
qDebug() << query.lastError();
}
необходимо по двойному клику на запись удалять её из tableWidget
int i = ui->tableWidget->selectionModel()->currentIndex().row();
ui->tableWidget->removeRow(i);
CLR не позволит и MessageBox привычным способом вызвать.
#include<Windows.h>
using namespace System;
int main(array<System::String ^> ^args)
{
#pragma comment(lib, "User32.lib")
MessageBox(NULL, L"Hello World!", L"Hello World Box", 0);
return 0;
}
p.s. название библиотеки поменялось
g++ main.cpp -o main.exe -lglfw3 //Компиляция происходит без проблем, а линковка дает ошибки
#include "glfw3.h"
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
undefined reference to `_imp__glClear@4'
то opengl32.a надо закинуть в project\libsusing an implementation-dependent algorithm or strategy
If you’re like me (with a front-end background and no CS degree) you look at this and think “Ok, variable assignment, variable assignment, function… simple enough…” but then you come to s1 ^= s1 << 23; and say “what the shit?”