Skip to content

Instantly share code, notes, and snippets.

using System;
class CalculateGCD
{
static void Main(string[] args)
{
// function gcd(a, b)
// while b ≠ 0
// t := b
// b := a mod b
using System;
using System.Collections.Generic;
//Write a program that reads from the console a sequence of
//n integer numbers and returns the minimal, the maximal number,
//the sum and the average of all numbers (displayed with 2 digits after the decimal point).
//The input starts by the number n (alone in a line) followed by n lines,
//each holding an integer number. The output is like in the examples below.
//Examples:
//input output
// 3 min = 1
using System;
//Write a program that finds the biggest of five numbers
//by using only five if statements.
class BiggestOf5Numbers
{
static void Main()
{
double a = double.Parse(Console.ReadLine());
double b = double.Parse(Console.ReadLine());
double c = double.Parse(Console.ReadLine());
using System;
//Write a program that shows the sign (+, - or 0)
//of the product of three real numbers,
//without calculating it. Use a sequence of if operators. Examples:
//a b c result
//5 2 2 +
//-2 -2 1 +
//-2 4 3 -
//0 -2.5 4 0
using System;
//Classical play cards use the following signs to designate the card face:
//2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K and A.
//Write a program that enters a string and prints “yes”
//if it is a valid card sign or “no” otherwise. Examples:
//character Valid card sign?
// 5 yes
// 1 no
// Q yes
// q no
using System;
//Write a program that applies bonus score to given score in the range
//[1…9] by the following rules:
//• If the score is between 1 and 3, the program multiplies it by 10.
//• If the score is between 4 and 6, the program multiplies it by 100.
//• If the score is between 7 and 9, the program multiplies it by 1000.
//• If the score is 0 or more than 9, the program prints “invalid score”.
//Examples:
//score result
//2 20
using System;
//Write an if-statement that takes two doubleeger variables a and b
//and exchanges their values if the first one is greater than the second one. As a result prdouble the values a and b, separated by a space. Examples:
// b result
//5 2 2 5
//3 4 3 4
//5.5 4.5 4.5 5.5
class ExchangeIfGreater
{
using System;
//Write a program that enters 3 real numbers and prints them
//sorted in descending order. Use nested if statements.
//Don’t use arrays and the built-in sorting functionality.
//Examples:
//a b c result
//5 1 2 5 2 1
//-2 -2 1 1 -2 -2
//-2 4 3 4 3 -2
using System;
//Write a program that finds the biggest of three numbers.
//Examples:
//a b c biggest
//5 2 2 5
//-2 -2 1 1
//-2 4 3 4
class BigestOf3Numbers
{
using System;
//Write a C# program to print on screen the result of adding, subtracting,
//multiplying and dividing two numbers typed by the user.
//The remainder of the division must be displayed, too.
//It might look like this:
//Enter a number: 12
//Enter another number: 3
//12 + 3 = 15
//12 - 3 = 9