亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

C#開發輕松入門

難度入門
時長 4小時43分
學習人數
綜合評分9.40
833人評價 查看評價
9.5 內容實用
9.5 簡潔易懂
9.2 邏輯清晰
  • 命名空間中有若干個類

    查看全部
  • for (int i = 1; i <= 7; i++)

    {

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

    ????{

    ????????Console.Write(i ==j || i + j == 8 ? 'O' : '.');

    ????}

    ????Console.WriteLine();

    }

    查看全部
    0 采集 收起 來源:編程練習

    2022-06-26

  • 10.各位相加

    給定一個非負整數 num,反復將各個位上的數字相加,直到結果為一位數。返回這個結果。

    輸入樣例1:

    在這里給出一組輸入。例如:

    38

    輸出樣例1:

    在這里給出相應的輸出。例如:

    2

    解釋樣例2:

    數字38各位相加的過程為:
    38 --> 3 + 8 --> 11
    11 --> 1 + 1 --> 2
    由于 2 是一位數,所以返回 2。

    輸入樣例2:

    在這里給出一組輸入。例如:

    0

    輸出樣例2:

    在這里給出相應的輸出。例如:

    0

    using System;


    class Program

    {

    ? ? static void Main()

    ? ? {

    ? ? ? ? int n = Convert.ToInt16(Console.ReadLine());

    ? ? ? ??

    ? ? ? ? while(n > 9)

    ? ? ? ? {

    ? ? ? ? ? ? int sum = 0;

    ? ? ? ? ? ? while(n != 0)

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? sum += n % 10;

    ? ? ? ? ? ? ? ? n /= 10;

    ? ? ? ? ? ? }

    ? ? ? ? ? ? n = sum;

    ? ? ? ? }


    ? ? ? ? Console.WriteLine(n);

    ? ? }

    ? ??

    }

    查看全部
    0 采集 收起 來源:練習題目

    2022-06-24

  • 8.尋找數組中的最小值

    尋找數組中最小值
    注意:

    數組中元素并不一定是整數

    輸入格式:

    第一行輸入為數組元素的個數,假設為n
    第二行輸入為數組中的第一個元素
    ...
    第N輸入為數組的最后一個元素

    輸出格式:

    輸出數組中的最小值

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;


    namespace ConsoleApplication1

    {

    ? ? class Program

    ? ? {

    ? ? ? ? static void Main(string[] args)

    ? ? ? ? {

    ? ? ? ? ? ? int num = Convert.ToInt32(Console.ReadLine());

    ? ? ? ? ? ? double[] arr = new double[num];

    ? ? ? ? ? ? double min = arr[0];

    ? ? ? ? ? ? for (int i = 0; i < arr.Length; i++)

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? arr[i] = double.Parse(Console.ReadLine());

    ? ? ? ? ? ? ? ? if (arr[i] < min)

    ? ? ? ? ? ? ? ? ? ? min = arr[i];

    ? ? ? ? ? ? }

    ? ? ? ? ? ? Console.WriteLine(min);

    ? ? ? ? }

    ? ? }

    }

    查看全部
    0 采集 收起 來源:練習題目

    2022-06-24

  • 7.尋找數組中的最大值

    尋找數組中最大值
    注意:

    數組中元素并不一定是整數

    輸入格式:

    第一行輸入為數組元素的個數,假設為n
    第二行輸入為數組中的第一個元素
    ...
    第N輸入為數組的最后一個元素

    輸出格式:

    輸出數組中的最大值

    using System;


    class Program

    {

    ? ? static void Main()

    ? ? {

    ? ? ? ? int n = Convert.ToInt16(Console.ReadLine());

    ? ? ? ? double max = -0x3f3f3f3f;


    ? ? ? ? for(int i = 0; i < n; ++i)

    ? ? ? ? {

    ? ? ? ? ? ? double tmp = Convert.ToDouble(Console.ReadLine());

    ? ? ? ? ? ? if(tmp > max)

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? max = tmp;

    ? ? ? ? ? ? }

    ? ? ? ? }


    ? ? ? ? Console.WriteLine(max);

    ? ? }

    ? ??

    }

    查看全部
    0 采集 收起 來源:練習題目

    2022-06-24

  • 6.計算整數n到整數m之間數的總和

    計算整數n到整數m之間數的總和

    輸入格式:

    第一行輸入整數n
    第二行輸入整數m

    輸出格式:

    輸出和

    using System;


    class Program

    {

    ? ? static void Main()

    ? ? {

    ? ? ? ? int n = Convert.ToInt16(Console.ReadLine());

    ? ? ? ? int m = Convert.ToInt16(Console.ReadLine());


    ? ? ? ? int sum = 0;

    ? ? ? ? for(int i = n; i <= m; ++i)

    ? ? ? ? {

    ? ? ? ? ? ? ? ? sum += i;

    ? ? ? ? }


    ? ? ? ? Console.WriteLine(sum);

    ? ? }

    ? ??

    }


    查看全部
    0 采集 收起 來源:練習題目

    2022-06-24

  • 5.求解分段函數

    編寫程序,求解如下分段函數:

    當x≤0時f(x)=x2+2

    當x>0時f(x)=x+3

    注意:

    x為整數

    輸入格式:

    輸入為x

    輸出格式:

    輸出為f(x)

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;


    namespace ConsoleApp1

    {

    ? ? internal class Program

    ? ? {

    ? ? ? ? static void Main(string[] args)

    ? ? ? ? {

    ? ? ? ? ? ? double x;

    ? ? ? ? ? ? x = Convert.ToDouble(Console.ReadLine());

    ? ? ? ? ? ? if (x <= 0)

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? Console.WriteLine(x*x+2);

    ? ? ? ? ? ? }

    ? ? ? ? ? ? else

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? Console.WriteLine(x+3);

    ? ? ? ? ? ? }

    ? ? ? ? }

    ? ? }

    }

    查看全部
    0 采集 收起 來源:練習題目

    2022-06-24

  • 4.查詢成績

    輸入一個成績:

    如果成績大于等于60,則輸出恭喜您,您通過了這次考試!

    否則輸出非常抱歉,您沒有通過此次考試!。

    注意:

    成績都為整數

    標點符號為中文標點符號

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;


    namespace ConsoleApplication1

    {

    ? ? class Program

    ? ? {

    ? ? ? ? static void Main(string[] args)

    ? ? ? ? {

    ? ? ? ? ? ? float cj;

    ? ? ? ? ? ? cj = Convert.ToSingle(Console.ReadLine());

    ? ? ? ? ? ? if (cj >= 60)

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? Console.WriteLine("恭喜您,您通過了這次考試!");

    ? ? ? ? ? ? }

    ? ? ? ? ? ? else?

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? Console.WriteLine("非常抱歉,您沒有通過此次考試!");

    ? ? ? ? ? ? }

    ? ? ? ? ? ??

    ? ? ? ? }

    ? ? }

    }


    查看全部
    0 采集 收起 來源:練習題目

    2022-06-24

  • 3.統計字符串中指定字符的數量

    統計字符串中指定字符的數量

    輸入格式:

    第一行輸入給定字符串
    第二行輸入給定字符

    輸出格式:

    輸出待統計字符個數

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;


    namespace ConsoleApp1

    {

    ? ? internal class Program

    ? ? {

    ? ? ? ? static void Main(string[] args)

    ? ? ? ? {

    ? ? ? ? ? ? string str;

    ? ? ? ? ? ? str = Console.ReadLine();

    ? ? ? ? ? ? int count = 0;

    ? ? ? ? ? ? char y;

    ? ? ? ? ? ? y = Convert.ToChar(Console.ReadLine());

    ? ? ? ? ? ? for(int i = 0; i < str.Length; ++i)

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? if (str[i] == y)

    ? ? ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? ? ? ++count;

    ? ? ? ? ? ? ? ? }

    ? ? ? ? ? ? }

    ? ? ? ? ? ? Console.WriteLine(count);

    ? ? ? ? }

    ? ? }

    }

    查看全部
    0 采集 收起 來源:練習題目

    2022-06-24

  • 2.求解互補數

    請編寫程序求解輸入數據的互補數,如果輸入數據小于0則打印字符串輸入數據不合法。互補數定義如下:

    兩個個位數(正整數)相加和為10的一對數,稱為互補數

    例如?: 1的互補數是9。

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;


    namespace ConsoleApplication1

    {

    ? ? class Program

    ? ? {

    ? ? ? ? static void Main(string[] args)

    ? ? ? ? {

    ? ? ? ? ? ? int a = Convert.ToInt32(Console.ReadLine());

    ? ? ? ? ? ? if (a < 0)

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? Console.WriteLine("輸入數據不合法");

    ? ? ? ? ? ? }

    ? ? ? ? ? ? else

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? Console.WriteLine("{0}", 10 - a);

    ? ? ? ? ? ? }

    ? ? ? ? }

    ? ? }

    }

    查看全部
    0 采集 收起 來源:練習題目

    2022-06-24

  • 1.統計n到m之間能被s整除的數的總和

    統計n到m之間(包括m)能被s整除的數的總和

    輸入格式:

    第一行輸入n,如1
    第二行輸入m,如100
    第三行輸入s,如3

    輸出格式:

    輸出結果,如1683

    using System;


    class Program

    {

    ? ? static void Main()

    ? ? {

    ? ? ? ? int n = Convert.ToInt16(Console.ReadLine());

    ? ? ? ? int m = Convert.ToInt16(Console.ReadLine());

    ? ? ? ? int s = Convert.ToInt16(Console.ReadLine());


    ? ? ? ? int sum = 0;

    ? ? ? ? for(int i = n; i <= m; ++i)

    ? ? ? ? {

    ? ? ? ? ? ? if(i % s == 0)

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? sum += i;

    ? ? ? ? ? ? }

    ? ? ? ? }


    ? ? ? ? Console.WriteLine(sum);

    ? ? }

    ? ??

    }

    查看全部
    0 采集 收起 來源:練習題目

    2022-06-24

  • for (int x = 1; x < 10; x++)

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ?if (x==3||x==8)

    ? ? ? ? ? ? ? ?continue;//請添加代碼,過濾3和8

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

    查看全部
  • C#中的switch,每個分支都應該以break;結束,break的作用是跳出switch結構。但是,如果某個分支中沒有語句,那么也可以不寫break;

    查看全部
    0 采集 收起 來源:練習題

    2022-05-25

  • switch?中的(變量)只能是3種類型:整型(如?int?)、字符型(?char?)、字符串類型(?string?)。

    查看全部
    0 采集 收起 來源:C#的switch結構

    2022-05-25

  • while循環

    先判斷循環條件,若條件為?true?,就執行循環體一次,然后再判斷條件...當條件為?false?時,結束循環。

    查看全部

舉報

0/150
提交
取消
課程須知
本課程是C#基礎課程,熱烈歡迎各位小伙伴拍磚吐槽??!
老師告訴你能學到什么?
1、C#的基本概念 2、Visual Studio的使用技巧 3、C#的語法和程序邏輯

微信掃碼,參與3人拼團

微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!