Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int Remainder(int a, int b) {
- return (a % b + b) % b;
- }
- int main0() {
- int n = 0, m = 0;
- std::cin >> n >> m;
- std::cout << Remainder(n, m) << std::endl;
- return 0;
- }
- int main1() {
- int n = 0;
- std::cin >> n;
- for (int j = 0; j < n; std::cout << j++); // Foo
- std::cout << std::endl;
- return 0;
- }
- int main2() {
- int n = 0;
- std::cin >> n;
- if (n = 3) std::cout << "Checked";
- std::cout << std::endl;
- return 0;
- }
- int main3() {
- int* n = new int;
- *n = 10;
- std::cout << *n << std::endl;
- std::cout << n << std::endl;
- std::cout << sizeof(n) << std::endl;
- std::cout << "Ok" << std::endl;
- return 0;
- }
- int main4() {
- long long* n = new long long[100];
- *n = 10;
- *(n + 5) = 47;
- std::cout << *n << std::endl;
- std::cout << *(n + 5) << std::endl;
- std::cout << n[6] << std::endl;
- std::cout << std::endl;
- for (int i = 0; i < 100; ++i) std::cout << n[i] << std::endl;
- std::cout << "Ok" << std::endl;
- return 0;
- }
- void f(int* p) {
- p = nullptr;
- *p = 6;
- }
- void f(int& p) {
- p = 6;
- }
- int main5() {
- int n = 5;
- f(n);
- std::cout << n << std::endl;
- return 0;
- }
- int main() {
- int n = 0;
- std::cin >> n;
- // Выведем все простые, меньшие n.
- // v[i] == true, если число простое
- // v[i] == false, если непростое (1 или составные)
- // 2, 4, 6, 8, ..... -> false
- // 3, 6, 9, 12, ... -> false
- int* a = new int[n];
- for (int i = 2; i < n; ++i) {
- a[i] = true;
- }
- for (int i = 2; i < n; ++i) {
- if (!a[i]) continue;
- for (int j = i + i; j < n; j += i) {
- a[j] = false;
- }
- }
- for (int i = 2; i < n; ++i) {
- if (a[i]) std::cout << i << " ";
- }
- delete[] a;
- std::cout << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement