Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <climits>
- using namespace std;
- int main() {
- //task 1
- /**/
- int max = INT_MIN;
- int min = INT_MAX;
- cout << "Enter ten numbers: " << endl;
- for(int i = 0; i < 10; i++){
- int number;
- cin >> number;
- if(number > max){
- max = number;
- }
- if(number < min){
- min = number;
- }
- }
- cout << "Maximum of ten numbers is " << max << endl;
- cout << "Minimum of ten numbers is " << min << endl;
- // task 2
- int lowerCaseCount, upperCaseCount, digitCount, symbolCount;
- lowerCaseCount = upperCaseCount = digitCount = symbolCount = 0;
- cout << "Enter ten characters: " << endl;
- for(int i = 0; i < 10; i++){
- char character;
- cin >> character;
- if(character >= 'a' && character <= 'z'){
- lowerCaseCount++;
- } else if(character >= 'A' && character <= 'Z'){
- upperCaseCount++;
- } else if(character >= '0' && character <= '9'){
- digitCount++;
- } else {
- symbolCount++;
- }
- }
- cout << "Lower cases: " << lowerCaseCount << endl;
- cout << "Upper cases: " << upperCaseCount << endl;
- cout << "Digits: " << digitCount << endl;
- cout << "Symbols: " << symbolCount << endl;
- // task 3
- cout << "Here we are gonna print all the consonants: " << endl;
- for(int i = 'A'; i <= 'Z'; i++){
- bool isConsonant = !(i == 'A' || i == 'E' || i == 'I' || i == 'U' || i == 'O');
- if(isConsonant){
- cout << (char)i << " ";
- }
- }
- // task 4
- int number;
- cout << "Enter a number: " << endl;
- cin >> number;
- int num = 1;
- cout << num;
- for(int i = 1; i < number; i++){
- num = num * 10 + 1;
- cout << " + " << num;
- }
- // task 5
- int number;
- cout << "Enter a number: " << endl;
- cin >> number;
- int temp = number, firstDigit, lastDigit = number % 10;
- while(temp != 0){
- if(temp < 10){
- temp = firstDigit;
- }
- temp /= 10;
- }
- cout << "The first digit of a number is " << firstDigit << endl;
- cout << "The last digit of a number is " << lastDigit << endl;
- if(firstDigit == lastDigit){
- cout << "The digits are equal." << endl;
- } else {
- cout << "The digits are not equal. " << endl;
- }
- // task 6
- int number;
- cin >> number;
- for(int i = 2; i < number / 2; i++){
- if(number % i == 0){
- bool flag = true;
- for(int j = 2; j < i / 2; j++){
- if(i % j == 0){
- flag = false;
- }
- }
- if(flag){
- cout << i << " ";
- }
- }
- }
- // task 7
- double a, b, c;
- for(size_t i = 1; i <= 50; i++){
- c = i;
- for(size_t j = 1; j <= 50; j++){
- b = j;
- for(size_t k = 1; k <= 50; k++){
- a = k;
- if(c * c * c == a * a + b * b){
- cout << a << " ," << b << " ," << c << endl;
- }
- }
- }
- }
- // task 8
- int x, y, x1, y1, radius;
- cin >> x >> y >> x1 >> y1 >> radius;
- bool isInCircle = ((x - x1) * (x - x1) + (y - y1) * (y - y1)) <= radius * radius;
- cout << boolalpha << isInCircle << endl;
- // task 9
- int low, high;
- bool isPrime = true;
- cout << "Enter an interval: " << endl;
- cin >> low >> high;
- while(low < high){
- isPrime = true;
- if(low == 0 || low == 1){
- isPrime = false;
- }
- for(int i = 2; i < low / 2; i++){
- if(low % i == 0){
- isPrime = false;
- break;
- }
- }
- if(isPrime){
- cout << low << " ";
- }
- low++;
- }
- // task 10
- int number, binary_number = 0, d = 1;
- cout << "Enter a number: " << endl;
- cin >> number;
- if(number < 0 || number > 1000){
- cout << "You'll gonna get the error!" << endl;
- } else {
- while(number != 0){
- binary_number += (number % 2) * d;
- d *= 10;
- number /= 2;
- }
- }
- cout << binary_number << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment