課程
/后端開發
/C#
/C#開發輕松入門
4-3的練習題怎么做
2016-10-18
源自:C#開發輕松入門 4-3
正在回答
if可以換成while嗎
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int x = 1;
? ? ? ? ? ? int sum = 0;//和,初始化為0
? ? ? ? ? ? while (x <= 30)//循環條件
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (x%2!=0)//篩選條件
? ? ? ? ? ? ? ? ? ? sum += x;
? ? ? ? ? ? ? ? x++;
? ? ? ? ? ? }
? ? ? ? ? ? Console.Write("1-30奇數的和:"+sum);
? ? ? ? }
? ? }
}
if(x%2==1)
額 我學晚了 人都學完走了 沒人鳥我
不會啊
舉報
本門課程是C#語言的入門教程,將帶你輕松入門.NET開發
2 回答為什么b=4>3;不行。
3 回答為什么4-3算法求和if不能換成while?
2 回答為什么x >=1了 最后輸出是4 3 2 1 0呢?
3 回答3-4編程練習,為什么不能提交?新手表示很憤怒
3 回答4-2
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-08-09
if可以換成while嗎
2016-11-08
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? int x = 1;
? ? ? ? ? ? int sum = 0;//和,初始化為0
? ? ? ? ? ? while (x <= 30)//循環條件
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (x%2!=0)//篩選條件
? ? ? ? ? ? ? ? ? ? sum += x;
? ? ? ? ? ? ? ? x++;
? ? ? ? ? ? }
? ? ? ? ? ? Console.Write("1-30奇數的和:"+sum);
? ? ? ? }
? ? }
}
2016-11-04
if(x%2==1)
2016-10-18
額 我學晚了 人都學完走了 沒人鳥我
2016-10-18
不會啊