Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int a, b;
- cin >> a >> b;
- if(a == 0){
- if(b == 0){
- cout << "INF" << endl;
- } else {
- cout << "No solution!" << endl;
- }
- } else {
- cout << "x = " << - b / a << endl;
- }
- int n;
- cin >> n;
- int i = 1;
- int f = 1;
- if(i <= n){
- f *= i;
- i++;
- } else {
- cout << f << endl;
- }
- int a, b;
- cin >> a >> b;
- if(a == 0 || b == 0){
- cout << "Error" << endl;
- } else {
- if(a == b){
- cout << a << endl;
- } else {
- if(a > b){
- cout << a = a - b;
- } else {
- cout << b = b - a;
- }
- }
- }
- int quotient, remainder, a, b;
- cout << "Enter divisor: " << endl;
- cin >> a;
- cout << "Enter dividend: " << endl;
- cin >> b;
- quotinet = a / b;
- remainder = a % b;
- cout << "Quotient: " << quotient << endl;
- cout << "Remaineder: " << remainder << endl;
- cout << "The size of int: " << sizeof(int) << endl;
- cout << "The size of double: " << sizeof(double) << endl;
- cout << "The size of bool: " << sizeof(bool) << endl;
- cout << "The size of char: " << sizeof(char) << endl;
- cout << "The size of long: " << sizeof(long) << endl;
- cout << "The size of short: " << sizeof(short) << endl;
- cout << "The size of long double: " << sizeof(long double) << endl;
- // swapping numbers
- int num1, num2;
- cin >> num1 >> num2;
- cout << "Before swapping numbers: " << endl;
- cout << "First number = " << num1 << "\n" << "Second number = " << num2 << endl;
- int temp = num1;
- num1 = num2;
- num2 = temp;
- cout << "After swapping numbers: " << endl;
- cout << "First number = " << num1 << "\n" << "Second number = " << num2 << endl;
- // even or odd number
- int n;
- cin >> n;
- if(n % 2 == 0){
- cout << "Even number! " << endl;
- } else if(n % 2 != 0) {
- cout << "Odd number! "
- }
- // check whether character is a consonant or vowel
- char symbol;
- cin >> symbol;
- if(symbol == 'a' || symbol == 'e' || symbol == 'i' || symbol == 'u' || symbol == 'o' || symbol == 'A' || symbol == 'E' || symbol == 'I' || symbol == 'O' || symbol == 'U'){
- cout << "Character is a vowel" << endl;
- } else {
- cout << "Character is a consonant " << endl;
- }
- // roots of quadratic equations
- int a, b, c, D;
- cin >> a >> b >> c;
- D = b * b - 4 * a * c;
- if(D > 0){
- cout << "x1 = " << ((- b - sqrt(D)) / 2 * a);
- cout << "x2 = " << ((- b + sqrt(D)) / 2 * a);
- } else if(D == 0){
- cout << "x1 = x2 = " << - b / (2 * a) << endl;
- } else {
- cout << "x1 = " << - b / (2 * a) << endl;
- }
- int a, b, c;
- cin >> a >> b >> c;
- if(a > b && a > c){
- cout << "Largest number is: " << a << endl;
- } else if(b > a && b > c){
- cout << "Largest number is: " << b << endl;
- } else {
- cout << "Largest number is: " << c << endl;
- }
- // check whether the year is Leap
- int year;
- cin >> year;
- bool isLeap = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
- cout << boolalpha << isLeap << endl;
- // bad things about FMI
- cout << "Velikova nqma da me skusa! " << endl;
- cout << "Bojilov ne e religiq" << endl;
- cout << "Algebrata ne proshtava!" << endl;
- // tip point
- int x, y, x1, y1, radius;
- cin >> x >> y >> c1 >> c2 >> radius;
- bool doesBelong = sqrt(x - x1) * (x - x1) + (y - y1) * (y - y1) <= radius * radius;
- cout << boolalpha << doesBelong << endl;
- // existing triangle
- double a, b, c;
- cin >> a >> b >> c;
- bool isProperTriangle = (a + b > c || a + c > b || b + c > a);
- int halfPerimeter = (a + b + c) / 2;
- double area = (sqrt(halfPerimeter(halfPerimeter - a) * (halfPerimeter - b) * (halfPerimeter - c)));
- double perimeter = a + b + c;
- cout << boolalpha << isProperTriangle << endl;
- cout << area << endl;
- cout << perimeter << endl;
- // determine sum, difference, product and division
- int a, b;
- cin >> a >> b;
- cout << "Sum of two numbers is: " << a + b << endl;
- cout << "Difference of two numbers is: " << a - b << endl;
- cout << "Multiplication of two numbers is: " << a * b << endl;
- cout << "Division of two numbers is: " << a / b << endl;
- // print all the digits of one numbers
- int n, sum = 0;
- cout << "Enter a 4-digit number: " << endl;
- cin >> n;
- int firstdigit = n / 1000;
- int seconddigit = (n / 100) % 10;
- int thirddigit = (n / 10) % 10;
- int forthdigit = n % 10;
- cout << "First digit: " << firstdigit << endl;
- cout << "Second digit: " << seconddigit << endl;
- cout << "Third digit: " << thirddigit << endl;
- cout << "Forth digit: " << forthdigit << endl;
- sum = firstdigit + seconddigit + thirddigit + forthdigit;
- cout << "The sum of digits: " << sum << endl;
- int reverse;
- reverse = (forthdigit * 1000) + (thirddigit * 100) + (seconddigit * 10) + firstdigit;
- cout << "Reverse number of original number is: " << reverse << endl;
- int a,b;
- cout << "Enter two numbers: " << endl;
- cin >> a >> b;
- int product = a * b;
- cout << product << endl;
- cout << "LastDigit: " << product % 10 << endl;
- cout << "Even or Odd? " << ((product % 10) % 2 == 0) << endl;
- int a, b;
- cin >> a >> b;
- cout << "Before Swapping: " << endl;
- cout << "First: " << a << "\n" << "Second: " << b << endl;
- a = a + b;
- b = a - b;
- a = a - b;
- // there is a second way
- int temp = a;
- a = b;
- b = temp;
- cout << "After swapping: " << endl;
- cout << "First: " << a << "\n" << "Second: " << b << endl;
- // divisor to other one
- int a, b;
- cout << "Enter two numbers: " << endl;
- cin >> a >> b;
- bool isDivisor = (a % b == 0);
- cout << boolalpha << "num1 = " << a << " and " << "num2 = " << b << " => " << isDivisor << endl;
- double a, b, c;
- cin >> a >> b >> c;
- bool isProperTriangle = (a + b > c && a + c > b && b + c > a);
- cout << boolalpha << isProperTriangle << endl;
- // determine max and min between three numbers
- double a, b, c;
- cin >> a >> b >> c;
- double max = a;
- double min = a;
- if(b > max){
- max = b;
- }
- if(c > max){
- max = c;
- }
- if(b < min){
- min = b;
- }
- if(c < min){
- min = c;
- }
- cout << "MAX: " << max << endl;
- cout << "MIN: " << min << endl;
- // determine if the number belong to interval
- int startInterval, endInterval;
- int x;
- cin >> x;
- cin >> startInterval >> endInterval;
- bool isInInterval = (x >= startInterval && x <= endInterval);
- cout << boolalpha << isInInterval << endl;
- // check if year is Leap
- int year;
- cin >> year;
- bool isLeap = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
- cout << boolalpha << isLeap << endl;
- // building a calculator
- int num1, num2;
- char choice;
- cout << "Enter first number: " << endl;
- cin >> num1;
- cout << "Enter second number: " << endl;
- cin >> num2;
- cout << "Enter a choice: " << endl;
- cin >> choice;
- switch(choice){
- case '+':
- cout << num1 << " + " << num2 << " = " << num1 + num2;
- break;
- case '-':
- cout << num1 << " - " << num2 << " = " << num1 - num2;
- break;
- case '*':
- cout << num1 << " * " << num2 << " = " << num1 * num2;
- break;
- case '/':
- if(num2 != 0){
- cout << num1 << " / " << num2 << " = " << num1 / num2;
- } else {
- break;
- }
- default:
- cout << "Invalid choice!" << endl;
- break;
- }
- char character;
- if(character >= 'a' && character <= 'z'){
- cout << "The lower case is corresponding to... " << (char) - 32;
- } else if(characer >= 'A' && character <= 'Z'){
- cout << "The upper case is correspoding to... " << (char) + 32;
- } else {
- cout << "Is not a letter!" << endl;
- }
- char character;
- cin >> character;
- if(character >= '0' && character <= '9'){
- cout << "it's a digit!" << endl;
- } else if(character >= 'a' && character <= 'z'){
- cout << "It's lowercase! " << endl;
- } else if(character >= 'A' && character <= 'Z'){
- cout << "It's uppercase! " << endl;
- } else {
- cout << "Is a special symbol! " << endl;
- }
- int month;
- cin >> month;
- switch(month){
- case 12:
- case 1:
- case 2:
- cout << "Winter " << endl;
- break;
- case 3:
- case 4:
- case 5:
- cout << "Spring" << endl;
- break;
- case 6:
- case 7:
- case 8:
- cout << "Summer " << endl;
- break;
- case 9:
- case 10:
- case 11:
- cout << "Autumn " << endl;
- break;
- default:
- cout << "Invalid month! " << endl;
- break;
- }
- int year, month;
- cout << "Enter year: " << endl;
- cin >> year;
- cout << "Enter month: " << endl;
- cin >> month;
- bool isLeap = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
- switch(month){
- case 1:
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- case 12:
- cout << 31 << endl;
- break;
- case 4:
- case 6:
- case 9:
- case 11:
- cout << 30 << endl;
- break;
- case 2:
- cout << isLeap + 28 << endl;
- break;
- default:
- cout << "Invalid month " << endl;
- break;
- }
- int n;
- cout << "Enter a 4-digit number: " << endl;
- cin >> n;
- if(n < 999 && n > 10000){
- cout << "You'll get the error!" << endl;
- } else {
- int firstdigit = n / 1000;
- int seconddigit = (n / 100) % 10;
- int thirddigit = (n / 10) % 10;
- int forthdigit = n % 10;
- int max = firstdigit;
- if(seconddigit > max){
- max = seconddigit;
- } else if(thirddigit > max){
- max = thirddigit;
- } else if(forthdigit > max){
- max = forthdigit;
- }
- cout << "Is the first digit even or odd? " << (firstdigit % 2 == 0)
- << "Is the first digit the biggest? " << (firstdigit == max) << endl;
- }
- int tomato, patoto, pepper, carrot, olive, flavours;
- bool hasFriend;
- cout << "Tomato: " << endl;
- cin >> tomato;
- cout << "Patoto: " << endl;
- cin >> patoto;
- cout << "Pepper: " << endl;
- cin >> pepper;
- cout << "Carrot: " << endl;
- cin >> carrot;
- cout << "Olive: " << endl;
- cin >> olive;
- cout << "Flavours: " << endl;
- cin >> flavours;
- cout << "Is there a friend? " << endl;
- cin >> hasFriend;
- bool studentSalad = (tomato <= '1' || patoto <= '2' || pepper <= '4' || carrot <= '3' || olive <= '3' || flavours <= '150');
- bool studentSoup = (tomato <= '2' || patoto <= '3' || pepper <= '5' || carrot <= '6' || olive <= '10' || flavours <= '200');
- bool studentGuvech = (tomato <= '5' || patoto <= '6' || pepper <= '12' || carrot <= '7' || olive <= '12' || flavours <= '300');
- bool isGoingToBeFeed = studentSalad || ((studentSoup || studentGuvech) && hasFriend);
- cout << (isGoingToBeFeed ? "Yes" : "No") << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment