Initial commit
This commit is contained in:
20
cpp/Основы/ввод.cpp
Normal file
20
cpp/Основы/ввод.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
/* Ввод
|
||||
Синтаксис: устройство >> переменная
|
||||
cin - console input - консоль как устройство ввода
|
||||
>> оператор ввода
|
||||
*/
|
||||
float num;
|
||||
cout << "Введи число: "; // *Отсутствует endl
|
||||
cin >> num;
|
||||
cout << "Число в квадрате: " << num * num << endl;
|
||||
|
||||
printf("Введи число: ");
|
||||
scanf("%f", &num); // Ввод в стиле C
|
||||
printf("Число, умноженное на 5: %f\n", num * 5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
33
cpp/Основы/вывод.cpp
Normal file
33
cpp/Основы/вывод.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
/* Вывод
|
||||
Синтаксис: устройство << данные
|
||||
cout - console out - консоль как устройство вывода
|
||||
<< - оператор вывода. При использовании этого синтаксиса способен конкатенировать строки.
|
||||
endl - '\n'
|
||||
*/
|
||||
cout << "Ever heard of rubber duck debugging?" << endl;
|
||||
cout << " __ " << endl;
|
||||
cout << " <(o )___-" << endl;
|
||||
cout << " ( .__> /" << endl;
|
||||
cout << " `----' " << endl;
|
||||
|
||||
printf("printf output: \n"); // Вывод в стиле C
|
||||
char t;
|
||||
t = 'f';
|
||||
printf("printf output char: %c\n", t);
|
||||
/*
|
||||
%[flags][width][.precision][length]specifier
|
||||
c - character, s - string, d/i - integer,
|
||||
o - unsigned integer (octal), x/X - unsigned integer (hexadecimal),
|
||||
u - unsigned integer (decimal), f/F - float (decimal),
|
||||
e/E - float (exponential), a/A - float (hexadecimal exponent),
|
||||
g/G - float (decimal/decimal exponential?),
|
||||
n - number of chars written by far using this call function,
|
||||
p - a pointer that points to the implementation-defined character sequence
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
19
cpp/Основы/комментарии.cpp
Normal file
19
cpp/Основы/комментарии.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
// Это комментарий
|
||||
|
||||
/*
|
||||
Это
|
||||
многострочный
|
||||
комментарий
|
||||
*/
|
||||
|
||||
/**
|
||||
Это комментарий для документации
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
25
cpp/Основы/переменные.cpp
Normal file
25
cpp/Основы/переменные.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
/*
|
||||
Синтаксис: тип имя;
|
||||
или: тип имя = значение;
|
||||
*/
|
||||
|
||||
int myInt;
|
||||
myInt = 5;
|
||||
float myFloat = 6.23;
|
||||
double myDouble = 6.2340282;
|
||||
|
||||
// Pointers
|
||||
int *myPointer;
|
||||
myPointer = &myInt; // создание ссылки
|
||||
cout << "Значение из указателя: " << *myPointer << endl; // Получение значения из ссылки
|
||||
|
||||
// None
|
||||
myPointer = nullptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user