2. 設計說明:
請撰寫程式,讓使用者輸入一個字串(不含文字),再分別輸出各個元素的ASCII碼,顯示如【ASCII code for 'Y' is 89】。
3. 輸入輸出:
輸入說明
一個字串
輸出說明
各元素的ASCII碼(不含文字)
範例輸入1
Ye20@#
範例輸出1
ASCII code for 'Y' is 89
ASCII code for 'e' is 101
ASCII code for '2' is 50
ASCII code for '0' is 48
ASCII code for '@' is 64
ASCII code for '#' is 35
4. 評分項目:
(1) 符合設計說明輸出正確格式配分 10作者: may 時間: 2024-1-8 23:18
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSA02
{
class CSA02
{
static void Main(string[] args)
{
try
{
string str = Console.ReadLine();
for(int i = 0; i <= str.Length - 1; i++)
{
Char x = Convert.ToChar(str.Substring(i, 1));
Console.WriteLine("ASCII code for '" + x + "' is " + Convert.ToByte(x).ToString());
}
}
catch
{
Console.Write("error");
}
Console.ReadKey();
}
}
}
複製代碼
作者: 李泳霖 時間: 2024-1-29 21:17
using ConsoleApp1;
using System;//程式庫呼叫
using System.ComponentModel.DataAnnotations;
using System.Linq.Expressions;
using ABC.qq;
class Program//負責一部分工作的人
{
const string dreams = "There are moments in life when you miss someone so much that " +
"you just want to pick them from your dreams and hug them for real! Dream what " +
"you want to dream;go where you want to go;be what you want to be,because you have " +
"only one life and one chance to do all the things you want to do";
static void Main()//method ..Entry Point 程式進入點
{
try
{
string str = Console.ReadLine();
for (int i = 0; i < str.Length; i++)
{
Char x = Convert.ToChar(str.Substring(i, 1));//每抓一個轉字元
Console.WriteLine("ASCII code for '" + x + "' is " + Convert.ToByte(x).ToString());//將指定之數字的字串表示,轉換為相等的 8 位元不帶正負號的整數。