1.计算变量b和变量c的值,并将它们的值输出到控制台上。
试题1.1
int a = 6;
int b = 5;
int c = (++b >= a) ? a*b : a/b;
试题1.2
int a = 6;
int b = 5;
bool c = a-- < b && ++a >= b;
2.计算变量b、变量b、变量c的值,并将它们的值输出到控制台上。
试题2.1
int a = 6;
int b = 5;
bool c = --a < ++b && ++a >= b;
试题2.1
int a = 6;
int b = 5;
bool c = --a < ++b || ++a >= b;
3.计算变量b、变量b、变量c的值,并将它们的值输出到控制台上。
int a = 6;
int b = 5;
int c = --a < ++b || ++a >= b ? 25 : 26;
4.计算直角三角形的面积,其中两条直角边分别为5,9。
5.改造上述程序,使其两条直接边的值可以让用户从控制台输入。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a = 6;
int b = 5;
int c = (++b >= a) ? a * b : a / b;
Console.WriteLine(b);
Console.WriteLine(c);
//int b = 5;
//int c = 36;
//int a = 6;
//int b = 5;
//bool c = a-- < b && ++a >= b;
//Console.WriteLine(b);
//Console.WriteLine(c);
//int b = 5;
//int c = false;
//int a = 6;
//int b = 5;
//bool c = --a < ++b && ++a >= b;
//Console.WriteLine(a);
//Console.WriteLine(b);
//Console.WriteLine(c);
//int a = 6;
//int b = 6;
//int c = true;
//int a = 6;
//int b = 5;
//bool c = --a < ++b || ++a >= b;
//Console.WriteLine(a);
//Console.WriteLine(b);
//Console.WriteLine(c);
//int a = 6;
//int b = 5;
//int c = true;
//int a = 6;
//int b = 5;
//int c = --a < ++b || ++a >= b ? 25 : 26;
//Console.WriteLine(a);
//Console.WriteLine(b);
//Console.WriteLine(c);
//int a = 5;
//int b = 6;
//int c = 25;
直焦三角形的底为
// int di = 5;
// //直角三角形的长为
// int chang = 9;
// //直角三角形的面积为
// int s = (di * chang) / 2;
// Console.WriteLine(s);
//string a = Console.ReadLine();
//double a1 = double.Parse(a);
//Console.WriteLine("输入三角形的底:" + a1);
//string b = Console.ReadLine();
//double b1 = double.Parse(b);
//Console.WriteLine("输入三角形的高:" + b1);
//double s = (a1 * b1) / 2;
//Console.WriteLine("三角形的面积:" + s);
// Console.Read();
}
}
}