2018-12-19

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Collections;

namespace ConsoleApplication1

{

? ? class Program

? ? {

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

? ? ? ? {

? ? ? ? ? ? try{

? ? ? ? ? ? ? ? Console.WriteLine("請輸入10個數(shù)");

? ? ? ? ? ? int[]nums=new int[10];

? ? ? ? ? ? int[] counts = new int[4];

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

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? Console.Write("請輸入第{0}個數(shù)",i+1);

? ? ? ? ? ? ? ? ? ? nums[i]=Convert.ToInt32(Console.ReadLine());

? ? ? ? ? ? ? ? ? ? switch (nums[i])

? ? ? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? ? ? case 1:

? ? ? ? ? ? ? ? ? ? ? ? ? ? counts[0] += 1;

? ? ? ? ? ? ? ? ? ? ? ? ? ? break;

? ? ? ? ? ? ? ? ? ? ? ? case 2:

? ? ? ? ? ? ? ? ? ? ? ? ? ? counts[1] += 1;

? ? ? ? ? ? ? ? ? ? ? ? ? ? break;

? ? ? ? ? ? ? ? ? ? ? ? case 3:

? ? ? ? ? ? ? ? ? ? ? ? ? ? counts[2] += 1;

? ? ? ? ? ? ? ? ? ? ? ? ? ? break;

? ? ? ? ? ? ? ? ? ? ? ? default:

? ? ? ? ? ? ? ? ? ? ? ? ? ? counts[3] += 1;

? ? ? ? ? ? ? ? ? ? ? ? ? ? break;

? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? Console.WriteLine("數(shù)字1的個數(shù):{0}", counts[0]);

? ? ? ? ? ? ? ? Console.WriteLine("數(shù)字2的個數(shù):{0}", counts[1]);

? ? ? ? ? ? ? ? Console.WriteLine("數(shù)字3的個數(shù):{0}", counts[2]);

? ? ? ? ? ? ? ? Console.WriteLine("非法數(shù)字的個數(shù):{0}", counts[3]);

? ? ? ? }

? ? ? ? ? ? catch

? ? ? ? ? ? {

? ? ? ? Console.WriteLine("您輸入的程序錯誤");

? ? ? ? ? ? }

? ? ? ? ? ? Console.ReadKey();

? ? ? ? ? ? }

? ? }

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 分享給大家一個很久之前寫的一個純C#控制臺 3D闖關(guān)游戲代碼 直接復(fù)制就可以用 初學(xué)者可以看看 學(xué)習(xí)一下編程思想還...
    Magic_Dong閱讀 4,437評論 3 0
  • 訓(xùn)練1: 某百貨商場當(dāng)日消費積分最高的8名顧客,他們的積分分別是18、25、7、36、13、2、89、63.編寫程...
    be1058558528閱讀 637評論 0 0
  • usingSystem; usingSystem.Collections.Generic; usingSystem...
    一只皮皮橙閱讀 152評論 0 0
  • 知識點: 注:int類型默認32位有大小范圍 且第一位為符號位 0 為正 1 為負 8.4作業(yè) A:1、風(fēng)力預(yù)警系...
    cGunsNRoses閱讀 1,172評論 0 0
  • HTML中寫表單的時候,寫入這段代碼 意思是在這里增加一個隱藏域。對于用戶來說,在頁面上隱藏域是不可見的。 隱藏域...
    輝夜乀閱讀 6,506評論 0 4

友情鏈接更多精彩內(nèi)容