using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _2012._12._27_基本练习题
{
class Program
{
static void Main(string[] args)
{
/*1. 从键盘上输入两个整数,求出它们的和*/
//Console.WriteLine("请输入第一个数字");
//int a = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("请输入第二个数字");
//int b = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("这2个数之和是:{0}",a+b);
//Console.ReadKey();
/* 2. 从键盘上输入三角形的底和高,求出三角形的面积。*/
//Console.WriteLine("请输三角形底边长度:");
//int a = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("请输入三角形的高:");
//int b = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("三角形的面积:{0}", (a * b)/2);
//Console.ReadKey();
/*3. 从键盘上输入数字星期,在屏幕上显示英文星期。*/
//Console.WriteLine("请输入你要输入的星期:");
//int a = Convert.ToInt32(Console.ReadLine());
//if (a == 1)
//{
// Console.WriteLine("Monday");
//}
//if (a == 2)
//{
// Console.WriteLine("Tuesday");
//}
//if (a == 3)
//{
// Console.WriteLine("Wednesday");
//}
//if (a == 4)
//{
// Console.WriteLine("Thursday");
//}
//if (a == 5)
//{
// Console.WriteLine("Friday");
//}
//if (a == 6)
//{
// Console.WriteLine("Saturday");
//}
//if (a == 7)
//{
// Console.WriteLine("Sunday ");
//}
//Console.ReadKey();
/*4.从键盘输入三个整数,将这三个数按从大到小的顺序排列起来*/
//int a, b, c, x;
//Console.WriteLine("请输入第三个整数:");
//a = Convert.ToInt32(Console.ReadLine());
//b = Convert.ToInt32(Console.ReadLine());
//c = Convert.ToInt32(Console.ReadLine());
//if (a < b)
//{
// x = b;
// b = a;
// a = x;
// if (a < c)
// {
// x = c;
// c = a;
// a = x;
// }
//}
//else if (a < c)
//{
// x = c;
// c = a;
// a = x;
// if (b < c)
// {
// x = c;
// c = b;
// b = x;
// }
//}
// Console.WriteLine("三个数从大到小的顺序是:{0}>{1}>{2}", a, b, c);
// Console.ReadKey();
/*5. 从键盘输入三个整数,在一个程序中既要求出最大值,还要求出最小值。*/
//Console.WriteLine("请输入三个数字");
//int max;
//int min;
//int a = Convert.ToInt32(Console.ReadLine());
//int b = Convert.ToInt32(Console.ReadLine());
//int c = Convert.ToInt32(Console.ReadLine());
//if (a>b)
//{
// max = a;
//}
//else
//{
// max = b;
//}
//if (max<c)
//{
// max = c;
//}
//if (a < b)
//{
// min = a;
//}
//else
//{
// min = b;
//}
//if (min > c)
//{
// max = c;
//}
//Console.WriteLine("最大值{0},最小值{1}",max,min);
//Console.ReadKey();
/* 6. 使用for循环编程求出1到100的和 */
//int sum = 0;
//for (int i = 0; i <= 100; i++)
//{
// sum += i;
//}
//Console.WriteLine(sum);
//Console.ReadKey();
/* 7. 使用do循环编程求出1到100的和 */
//int i = 0;
//int sum = 0;
//do
//{
//sum += i;
// i++;
//} while (i<=100);
//Console.WriteLine(sum);
//Console.ReadKey();
/* 8. 使用while循环编程求出1到100的和 */
//int i = 0;
//int sum = 0;
//while (i<=100)
//{
// sum = sum + i;
// i++;
//}
//Console.WriteLine(sum);
//Console.ReadKey();
// 9. 从键盘输入10个整数,求出最小值
//int[] shuzi = new int[10];
//int x;
//Console.WriteLine("请输入10个数:");
//for (int i = 0; i < 10; i++)
//{
// shuzi[i] = Convert.ToInt32(Console.ReadLine());
//}
//x = shuzi[0];//将数组中的第一个数取出
//for (int i = 1; i < 10; i++)
//{
// if (x > shuzi[i])//前一个数与后一个数比较,取出最小的值
// {
// x = shuzi[i];
// }
//}
//Console.WriteLine("10个整数中最小的是:{0}", x);
//Console.ReadKey();
/*10. 求出8的阶乘。*/
//Console.WriteLine("输入你要输入的数:");
//int n = int.Parse(Console.ReadLine());
//int sum = 1;
//for (int i = 0; i < n; i++)
//{
// sum *= (i+1);
//}
//Console.WriteLine("{0}的阶乘等于:{1}",n,sum);
//Console.ReadKey();
/*11.输入“中华人民共和国”输出反向结果“国和共民人华中”*/
//string zfc = "我是中国人";
//char[] arry = zfc.ToCharArray();
//Array.Reverse(arry);
//zfc = new string(arry);
//Console.WriteLine(zfc);
//Console.ReadKey();
/*12.滚动的皮球,在控制台中输出一个“|”“-” 每个100毫秒向后移动
* 一个空格直至到达这一行的末尾,换行继续输出。直到屏幕的最后。*/
//int a, b,x;
//Console.WriteLine("请输入一个加法表达式:");
//string str = Console.ReadLine().ToString();
//bool z = str.Contains("+");//判断是否含有+
//if (z==false)
//{
// Console.WriteLine("表达式错误,请重新输入:");
// return;
//}
//x = str.IndexOf("+");//通过索引找到字符串中+的位置
//a = Convert.ToInt32(str.Substring(0, x));
//b = Convert.ToInt32(str.Substring(x+1));
//Console.WriteLine("输出计算结果:{0}+{1}={2}",a,b,a+b);
//Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _2012._12._27_基本练习题
{
class Program
{
static void Main(string[] args)
{
/*1. 从键盘上输入两个整数,求出它们的和*/
//Console.WriteLine("请输入第一个数字");
//int a = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("请输入第二个数字");
//int b = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("这2个数之和是:{0}",a+b);
//Console.ReadKey();
/* 2. 从键盘上输入三角形的底和高,求出三角形的面积。*/
//Console.WriteLine("请输三角形底边长度:");
//int a = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("请输入三角形的高:");
//int b = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine("三角形的面积:{0}", (a * b)/2);
//Console.ReadKey();
/*3. 从键盘上输入数字星期,在屏幕上显示英文星期。*/
//Console.WriteLine("请输入你要输入的星期:");
//int a = Convert.ToInt32(Console.ReadLine());
//if (a == 1)
//{
// Console.WriteLine("Monday");
//}
//if (a == 2)
//{
// Console.WriteLine("Tuesday");
//}
//if (a == 3)
//{
// Console.WriteLine("Wednesday");
//}
//if (a == 4)
//{
// Console.WriteLine("Thursday");
//}
//if (a == 5)
//{
// Console.WriteLine("Friday");
//}
//if (a == 6)
//{
// Console.WriteLine("Saturday");
//}
//if (a == 7)
//{
// Console.WriteLine("Sunday ");
//}
//Console.ReadKey();
/*4.从键盘输入三个整数,将这三个数按从大到小的顺序排列起来*/
//int a, b, c, x;
//Console.WriteLine("请输入第三个整数:");
//a = Convert.ToInt32(Console.ReadLine());
//b = Convert.ToInt32(Console.ReadLine());
//c = Convert.ToInt32(Console.ReadLine());
//if (a < b)
//{
// x = b;
// b = a;
// a = x;
// if (a < c)
// {
// x = c;
// c = a;
// a = x;
// }
//}
//else if (a < c)
//{
// x = c;
// c = a;
// a = x;
// if (b < c)
// {
// x = c;
// c = b;
// b = x;
// }
//}
// Console.WriteLine("三个数从大到小的顺序是:{0}>{1}>{2}", a, b, c);
// Console.ReadKey();
/*5. 从键盘输入三个整数,在一个程序中既要求出最大值,还要求出最小值。*/
//Console.WriteLine("请输入三个数字");
//int max;
//int min;
//int a = Convert.ToInt32(Console.ReadLine());
//int b = Convert.ToInt32(Console.ReadLine());
//int c = Convert.ToInt32(Console.ReadLine());
//if (a>b)
//{
// max = a;
//}
//else
//{
// max = b;
//}
//if (max<c)
//{
// max = c;
//}
//if (a < b)
//{
// min = a;
//}
//else
//{
// min = b;
//}
//if (min > c)
//{
// max = c;
//}
//Console.WriteLine("最大值{0},最小值{1}",max,min);
//Console.ReadKey();
/* 6. 使用for循环编程求出1到100的和 */
//int sum = 0;
//for (int i = 0; i <= 100; i++)
//{
// sum += i;
//}
//Console.WriteLine(sum);
//Console.ReadKey();
/* 7. 使用do循环编程求出1到100的和 */
//int i = 0;
//int sum = 0;
//do
//{
//sum += i;
// i++;
//} while (i<=100);
//Console.WriteLine(sum);
//Console.ReadKey();
/* 8. 使用while循环编程求出1到100的和 */
//int i = 0;
//int sum = 0;
//while (i<=100)
//{
// sum = sum + i;
// i++;
//}
//Console.WriteLine(sum);
//Console.ReadKey();
// 9. 从键盘输入10个整数,求出最小值
//int[] shuzi = new int[10];
//int x;
//Console.WriteLine("请输入10个数:");
//for (int i = 0; i < 10; i++)
//{
// shuzi[i] = Convert.ToInt32(Console.ReadLine());
//}
//x = shuzi[0];//将数组中的第一个数取出
//for (int i = 1; i < 10; i++)
//{
// if (x > shuzi[i])//前一个数与后一个数比较,取出最小的值
// {
// x = shuzi[i];
// }
//}
//Console.WriteLine("10个整数中最小的是:{0}", x);
//Console.ReadKey();
/*10. 求出8的阶乘。*/
//Console.WriteLine("输入你要输入的数:");
//int n = int.Parse(Console.ReadLine());
//int sum = 1;
//for (int i = 0; i < n; i++)
//{
// sum *= (i+1);
//}
//Console.WriteLine("{0}的阶乘等于:{1}",n,sum);
//Console.ReadKey();
/*11.输入“中华人民共和国”输出反向结果“国和共民人华中”*/
//string zfc = "我是中国人";
//char[] arry = zfc.ToCharArray();
//Array.Reverse(arry);
//zfc = new string(arry);
//Console.WriteLine(zfc);
//Console.ReadKey();
/*12.滚动的皮球,在控制台中输出一个“|”“-” 每个100毫秒向后移动
* 一个空格直至到达这一行的末尾,换行继续输出。直到屏幕的最后。*/
//int a, b,x;
//Console.WriteLine("请输入一个加法表达式:");
//string str = Console.ReadLine().ToString();
//bool z = str.Contains("+");//判断是否含有+
//if (z==false)
//{
// Console.WriteLine("表达式错误,请重新输入:");
// return;
//}
//x = str.IndexOf("+");//通过索引找到字符串中+的位置
//a = Convert.ToInt32(str.Substring(0, x));
//b = Convert.ToInt32(str.Substring(x+1));
//Console.WriteLine("输出计算结果:{0}+{1}={2}",a,b,a+b);
//Console.ReadKey();
}
}
}