//1、風力預警系統有如下標準:普通風力小于5級,為藍色;大于5小于8,為黃色;大于8小于10為橙色;大于10位紅色。
//如果風為龍卷風或臺風等特殊情況,大于8級即為紅色,實現上述判定標準,輸入風力級別,輸出預警顏色。
//1是特殊風 2 反之為特殊風;
// Console.WriteLine ("1是普通風,2是特殊風");
// string c=Console.ReadLine();
//
// Console.WriteLine ("請繼續輸入風力級別");
// int a=int.Parse(Console.ReadLine());//a是風力級別
//
//
// switch (c) {
// case"1":
// {
// if (a < 5) {
// Console.WriteLine ("風力預警藍色");
// } else {
// if (a < 8) {
// Console.WriteLine ("風力預警黃色");
// } else {
// if (a < 10) {
// Console.WriteLine ("風力預警橙色");
// } else {
// Console.WriteLine ("風力預警紅色");
// }
// }
// }
// break;
// }
// case"2":
// {
// Console.WriteLine ("這是龍卷風,請繼續輸入風力級別");
//
// if (a > 8&&a<=12) {
// Console.WriteLine ("風力預警紅色");
// } else {
// Console.WriteLine ("風力很小無所謂了");
// }
// break;
// }
// }
//2、實現一個程序,控制臺實現如下效果,現在控制臺輸出如下語句。
// 請輸入編號選擇您想購買的商品:
// 1、筆? ? ? 2、作業本? ? 3、橡皮擦? ? 4、直尺
//
// 用戶輸入編號后打印出用戶選擇的商品
// Console.WriteLine ("請輸入編號選擇您想購買的商品:1.筆? 2、作業本 3、橡皮擦? 4、直尺");
// string age=Console.ReadLine();
// switch (age) {
// case"1":{
// Console.WriteLine ("筆");
// break;
// }
// case"2":{
// Console.WriteLine ("作業本");
// break;
// }
// case"3":{
// Console.WriteLine ("橡皮擦");
// break;
// }
// case"4":{
// Console.WriteLine ("直尺");
// break;
// }
// }
//3、實現在控制臺輸入數據n, 計算n并打印出n的階乘;n!
//n!= 1*2*3*4*....*(n-1)*n
// int n=int.Parse(Console.ReadLine());
// int a,b=1;
// for(a=1;a<=n;a++) {
// b = b * a;
//
// }
// Console.WriteLine ("{0}", b);
//4
// int i, j;
// for (i = 2; i < 100;i++ )
// {
// for (j = 2; j <=i/2; j++)
// {
// if (i % j == 0)
// break;//只是跳出包含他的循環,并且當外部循環重新運行是
// }
// if (j > i / 2)
// Console.WriteLine("質數: " + i);
// }
//5
// Console.WriteLine ("請輸入一個數");
// int n=int.Parse(Console.ReadLine());
// if (n % 4 == 0) {
// if (n % 100 != 0) {
// if (n % 400 == 0) {
// Console.WriteLine ("這是閏年");
// } else {
// Console.WriteLine ("這是平年");
// }
// } else {
// Console.WriteLine ("這是閏年");
// }
//
// } else {
// Console.WriteLine ("這是平年");
// }
//6
// float num=0;
//
// for(int ab=1;ab<=7;ab++){
// Console.WriteLine ("請輸入星期{0}",ab);
// string c=Console.ReadLine();
// Console.WriteLine ("溫度{0}",c);
// num +=float.Parse(c);
// }
// Console.WriteLine ("這周的平均溫度是{0}",num/7.0f);
// int? xingqi=7;
// Console.WriteLine ("請輸入星期一的溫度");
// int a=int.Parse(Console.ReadLine());
// Console.WriteLine ("請輸入星期2的溫度");
// int b=int.Parse(Console.ReadLine());
// Console.WriteLine ("請輸入星期3的溫度");
// int c=int.Parse(Console.ReadLine());
// Console.WriteLine ("請輸入星期4的溫度");
// int d=int.Parse(Console.ReadLine());
// Console.WriteLine ("請輸入星期5的溫度");
// int e=int.Parse(Console.ReadLine());
// Console.WriteLine ("請輸入星期6的溫度");
// int f=int.Parse(Console.ReadLine());
// Console.WriteLine ("請輸入星期7的溫度");
// int g=int.Parse(Console.ReadLine());
// Console.WriteLine ("這周的平均溫度是",(a+b+c+d+e+f+g)/xingqi);
//7
//猴子第10天摘了1個桃子
// int a=1;
// for (int b = 9; b >=1; b--) {//9-766 8-382 7-190 6-94 5-46 4-22 3-10 2-4? 1-1? 10-1534
// //Console.WriteLine ("天數{0}",b );
// a = (a + 1) * 2;
// Console.WriteLine ("天數{0},吃了{1}",b,a );
// }
// Console.WriteLine ("一共是{0}",a );
//8
// int a = 1, b = 3;
// a += b %= 2;//先算%? 在算+
// Console.WriteLine ("{0},{1}",a,b );
// int a = 2,b = 5;
// a = ++b/a++;//a在前 先運算在++;
// Console.WriteLine ("{0},{1}",a,b );
//9如何用代碼將以下數據轉換成二進制和十六進制,1000和2049。
//2進制
// Console.WriteLine ("請輸入一個數");
// int? a =int.Parse( Console.ReadLine ());
// for (int num = 1; num<10; num++) {
// a = a % 2;
// Console.WriteLine ("{0}",a);
// }
int x=1000;
//十進制轉二進制
int [] binary=new int[16];//定義一個寬為16位的數組
int index = 0;//數組位數的位置 0位首位;
// while (x >0) {
// int n = x % 2; //是int值
// binary [index] =n;
// ++index;
// Console.WriteLine ("{0}", n);
// x /= 2;
// }
// for (int i = binary.Length - 1; i >= 0; --i) {
// Console.Write ("{0}", binary [i]);
// }
//0x3e8 = 8*16^0+E*16^1+3*16^2 = 1000
//十進制轉16
while(x>0){
int n = x % 16;//當X第一次帶進來時? n位第一個余數;
// if (n >= 10) {
// Console.Write ("{0}", (char)(n + 55));
// } else {
// Console.Write ("{0}", n);
// }
binary[index]=n;//把第一個余數賦值給 空的數組
++index;//位數+1;
x /= 16;
}
for (int i=binary.Length-1;i>=0;--i){
int n = binary [i];