Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Задача 1)
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- for (int i = 1; i <= n; i++){
- cout << i << endl;
- }
- return 0;
- }
- ========================================================
- Задача 2)
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "Dec Char" << endl;
- for (int i = 0; i <= 127; i++){
- cout << i << " = " << char(i) << endl;
- }
- }
- ========================================================
- Задача 3)
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cout << "Number: ";
- cin >> n;
- for (int i = 1; i < n; i++) {
- if (i % 2 == 0){
- cout << i << endl;
- }
- }
- }
- ========================================================
- Задача 4)
- #include <iostream>
- using namespace std;
- int main() {
- int a, b;
- cin >> a;
- cin >> b;
- for (a; a <= b; a++){
- cout << a << endl;
- }
- return 0;
- }
- ========================================================
- Задача 5)
- #include <iostream>
- using namespace std;
- int main() {
- int a, b, x;
- cin >> a;
- cin >> b;
- cin >> x;
- for (a; a <= b; a++){
- if (a % x == 0){
- cout << a << endl;
- }
- }
- return 0;
- }
- ========================================================
- Задача 6)
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- int main() {
- int n, sum_of_nums;
- cout << "Number n: ";
- cin >> n;
- sum_of_nums = 0;
- for (int i = 1; i <= n; i++){
- sum_of_nums += i;
- }
- cout << "Sum of all numbers: " << sum_of_nums;
- return 0;
- }
- ========================================================
- Задача 7)
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- int main() {
- int n, mul_of_nums;
- cout << "Number n: ";
- cin >> n;
- mul_of_nums = 1;
- for (int i = 1; i <= n; i++){
- mul_of_nums *= i;
- }
- cout << "Multiplication of all numbers: "<< mul_of_nums;
- return 0;
- }
- ========================================================
- Задача 8)
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n, num, sum_of_numbers, mul_of_numbers;
- list <int> numbers;
- cout << "Enter numbers count: ";
- cin >> n;
- for (int i = 0; i < n; i++){
- cin >> num;
- numbers.push_back(num);
- }
- sum_of_numbers = accumulate(numbers.begin(), numbers.end(), 0);
- mul_of_numbers = accumulate(numbers.begin(), numbers.end(), 1, multiplies<int>());
- cout << "\nSum = " << sum_of_numbers << endl;
- cout << "Multiplication = " << mul_of_numbers;
- return 0;
- }
- ========================================================
- Задача 9)
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <iostream>
- using namespace std;
- int main()
- {
- int array[50];
- int i, max, min, size, positive_count;
- cout<<"Enter size of the array: ";
- cin>>size;
- cout<<"\nEnter "<<size <<" elements in the array: " << endl;
- for(i=0; i<size; i++)
- cin>>array[i];
- max = array[0];
- min = array[0];
- positive_count = 0;
- for(i=1; i<size; i++) {
- if(array[i] > 0)
- positive_count += 1;
- if(array[i] > max)
- max = array[i];
- if(array[i] < min)
- min = array[i];
- }
- cout << "\nMaximum element: " << max << endl;
- cout << "Minimum element: " << min << endl;
- cout << "Positve numbers count: " << positive_count;
- return 0;
- }
Add Comment
Please, Sign In to add comment