-
代碼供參考:
using?System; using?System.Collections.Generic; using?System.Text; namespace?Test { ????class?Program ????{ ????????static?void?Main(string[]?args) ????????{ ????????????int?y?=?5; ????????????while?(y?>?0)//請輸入 ????????????{ ????????????????Console.Write(y+"?"); ????????????????y--;//請輸入 ????????????} ????????} ????} }
查看全部 -
using?System; using?System.Collections.Generic; using?System.Text; namespace?Test { ????class?Program ????{ ????????static?void?Main(string[]?args) ????????{ ????????????int?x=1; ????????????bool?a?=?++x?*?x?>?3;//true?x=1?運行后x=2,2?*?2?=?4?>3 ????????????bool?b?=?x>1?;//請賦值 ????????????Console.WriteLine(a==b); ????????} ????} }
查看全部 -
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? double x, y;
? ? ? ? ? ? x = y = 2;//從右向左賦值,x、y的值都是2
? ? ? ? ? ? x /= 0.5;//x=x/0.5 x=4
? ? ? ? ? ? y = 0;
? ? ? ? ? ? Console.WriteLine(x-y);
? ? ? ? }
? ? }
}
查看全部 -
雙精度浮點型?double?,存儲小數(shù),例如:
查看全部 -
整數(shù)類型?int?,存儲整數(shù),例如
查看全部 -
字符串類型?string?,存儲用“”(雙引號)括起來的一串字符,例如:
查看全部 -
字符類型?char?,存儲用 '' (單引號)括起來的一個字符,例如:
查看全部 -
using?System; using?System.Collections.Generic; using?System.Text; namespace?Test { ????class?Program ????{ ????????static?void?Main(string[]?args) ????????{ ????????????double?x?=?3.5; ????????????int?y?=?3; ????????????Console.WriteLine((double)x>y); ????????} ????} }
查看全部 -
需要申明變量 string temp;
查看全部 -
double 型強制轉(zhuǎn)換為int型將失去小數(shù)部分,比如(int)2.8,我們得到的將是2。查看全部
-
2個條件都是“必須”做到,那就需要同時滿足,適合用邏輯與(&&)連接:
||?二者居其一即可
查看全部 -
! 取反? ?即“真變假”或“假變真”
&& 一票否決? ?只有當(dāng)&&兩邊的表達式均為?true?時,整個表達式才為?true?;若任意一個表達式為?false?,整個表達式即為?false?。
||一票表決? ?只有當(dāng)&&兩邊的表達式均為?true?時,整個表達式才為?true?;若任意一個表達式為?false?,整個表達式即為?false?。
查看全部 -
1111111111
查看全部 -
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ?????char sex = '男';
????????????? int age = 21;
????????????? if (sex == '女')
??????????????{
????????????????????if(age >= 20)
????????????????????{
????????????????????????Console.WriteLine("達到法定年齡");
????????????????????}
????????????????????else
????????????????????{
????????????????????????Console.WriteLine("沒有達到呦");
?????????????????????}
????????????????}
????????????????else
????????????????{
????????????????????if(age >= 22)
????????????????????{
????????????????????????Console.WriteLine("達到法定年齡");
????????????????????}
????????????????????else
????????????????????{
????????????????????????Console.WriteLine("沒有達到!");
????????????????????}
????????????????}
? ? ? ? }
? ? }
}
查看全部 -
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? double x = 13.9, y = 24.4;
????????????double sum = x + y ;
????????????double avg = sum /2;
????????????Console.WriteLine(avg);
? ? ? ? }
? ? }
}
查看全部
舉報