第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

關(guān)于for循環(huán)和while循環(huán)的轉(zhuǎn)換

static void Main(string[] args)
??????? {
??????????? for (int y = 1; y <= 7; y++)
??????????? {
??????????????? for (int x = 1; x <= y; x++)
??????????????? {
??????????????????? Console.Write(x);
??????????????? }
??????????????? Console.WriteLine();//換行
??????????? }
??????? }

第二個(gè)for循環(huán)能改成while循環(huán)嗎?本人愚拙,望大神賜教。

正在回答

2 回答

for (int y = 1; y <= 7; y++)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? for (int x = 1; x <= 7; x++)

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? if(x<=y)

? ? ? ? ? ? ? ? ? ? Console.Write(x);

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? Console.WriteLine();//換行

? ? ? ? ? ? }


1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

qq_慕容831212

是(y<x)你這個(gè)會(huì)全輸出空白
2019-03-17 回復(fù) 有任何疑惑可以回復(fù)我~

可以改但是得先聲明變量x

static void Main(string[] args)
??????? {
? ? ? ? ? ? int x = 1

????????????for (int y = 1; y <= 7; y++)
??????????? {
??????????????? while(x <= y)
??????????????? {
??????????????????? Console.Write(x);

????????????????????x++:
??????????????? }
??????????????? Console.WriteLine();//換行
??????????? }
??????? }


2 回復(fù) 有任何疑惑可以回復(fù)我~
#1

故月晚風(fēng) 提問(wèn)者

不行啊 試過(guò)了,輸出不是一樣的呀
2018-04-28 回復(fù) 有任何疑惑可以回復(fù)我~
#2

慕少135454 回復(fù) 故月晚風(fēng) 提問(wèn)者

int x=1;
2018-05-11 回復(fù) 有任何疑惑可以回復(fù)我~
#3

慕沐3564631

int x=1;這一句應(yīng)該放到for循環(huán)里面才行
2019-04-17 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

關(guān)于for循環(huán)和while循環(huán)的轉(zhuǎn)換

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)