728x90
SMALL

using System;
class Program
{
    static void Main()
    {
        // 自分の得意な言語で
        // Let's チャレンジ!!
        var line = Console.ReadLine();
        line = line.Replace("a", "");
        line = line.Replace("i", "");
        line = line.Replace("u", "");
        line = line.Replace("e", "");
        line = line.Replace("o", "");
        line = line.Replace("A", "");
        line = line.Replace("I", "");
        line = line.Replace("U", "");
        line = line.Replace("E", "");
        line = line.Replace("O", "");
        
        Console.WriteLine(line);
    }
}

 

 

영어 이름을 입력받았을 때 모음을 없앤 내용을 출력하는 문제.

728x90

설정

트랙백

댓글

728x90
SMALL

위에 받는 숫자 A가 주식을 매수한 가격이고, 아래에 받는 숫자 B가 매도한 가격이다.

매수한 가격이 매도한 가격보다 높으면 손해니까 No를 출력하게 하고 그 반대는 Yes를 출력하게 한다. A랑 B가 같은 경우는 없다.

 

using System;
class Program
{
    static void Main()
    {
        // 自分の得意な言語で
        // Let's チャレンジ!!
        var line = Console.ReadLine();
        var line2 = Console.ReadLine();
        
        if(int.Parse(line) > int.Parse(line2))
        {
            Console.WriteLine("No");    
        }
        else
        {
            Console.WriteLine("Yes");
        }
        
    }
}

728x90

설정

트랙백

댓글

728x90
SMALL

using System;
class Program
{
    static void Main()
    {
        // 自分の得意な言語で
        // Let's チャレンジ!!
        var line = Console.ReadLine();
        
        for(int i = 0;i<line.Length+1;i++)
        {
            Console.Write("+");    
        }
        
        Console.WriteLine("+");
        Console.WriteLine("+" + line + "+");
        
        for(int i = 0;i<line.Length+2;i++)
        {
            Console.Write("+");    
        }
    }
}

728x90

설정

트랙백

댓글

728x90
SMALL

/////////////

//////////

예외처리: 실행시에 발생하는 문제에 대응

메리트: 프로그램을 안정하여 동작하게 하는 시스템의 품질을 높임.

에러 메시지도 읽어서 취할 수 있다.

기술한 소스 코드 > 컴파일러(실행 가능한 형식으로 변환) > 실행한다.(순차, 계산이나 처리를 진행한다)

컴파일 에러 à 의 실수, 문법의 틀림 등.

실행 에러 à 실행 시에 에러: 계산할 수 없다. 파일이 없다 등

예외처리 기능

Try: 미리 코드를 지정하여, 프로그램을 실행했을 때에 처리의 문제를 검출한다.

Catch: 문제를 검출할 때, 어떻게 대응할 지를 기술해 둔다.

Throw: 프로그램 실행 중에 예외가 발생한 것을 통지한다.

예외가 발생하는 예

0으로 나눴을 때, 수치 변환에서 숫자가 아닌 문자를 지정, 배열의 범위 외에 억세스, 파일이 없음.

//////////

////

// な例外理をしてみよう

using System;

 

class Lesson10

{

    public static void Main()

    {

 

Console.WriteLine("Hello World");

int number = 2;

//int number =0으로 하면 실행이 되지 않는다.

int answer = 100 / number;

Console.WriteLine(answer);

Console.WriteLine("Hello C#");

 

    }

}

 

///

/////////

 

 

///

///////

// な例外理をしてみよう

using System;

 

class Lesson10

{

    public static void Main()

    {

 

Console.WriteLine("Hello World");

try

{

int number = 0;

int answer = 100 / number;

Console.WriteLine(answer);

 

}

catch(Exception e)

//exception 오브젝트가 메시지로 출력한다.

{

Console.WriteLine(e.Message);

}

//예외처리

finally

{

Console.WriteLine("Hello C#");

}

    }

}

//////

728x90

'프로그래밍' 카테고리의 다른 글

C# 탭 컨트롤1  (0) 2020.09.09
C#에서 탭 컨트롤 넣기  (0) 2020.09.09
C# paiza 79 - RPG 아이템 일람 재현  (0) 2020.05.23
C# paiza 78 - 화상이미지 출력  (0) 2020.05.23
C# paiza 77 - 딕셔너리 루프  (0) 2020.05.23

설정

트랙백

댓글

728x90
SMALL

////

 

// RPGのアイテム一を再現しよう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        var itemImages = new Dictionary<string, string>();

        itemImages.Add("", "http://paiza.jp/learning/images/sword.png");

        itemImages.Add("", "http://paiza.jp/learning/images/shield.png");

        itemImages.Add("回復", "http://paiza.jp/learning/images/potion.png");

        itemImages.Add("クリスタル", "http://paiza.jp/learning/images/crystal.png");

 

        string[] items = {"回復", "", "", "回復", "クリスタル", "クリスタル" };

 

        // アイテム名とURLを出力する

     foreach(var item in items)

     {

         Console.WriteLine(item);

         Console.WriteLine(itemImages[item]);

        

     }

    

       

    }

}

/////////

 

/////

////

 

레슨9 종료

728x90

'프로그래밍' 카테고리의 다른 글

C#에서 탭 컨트롤 넣기  (0) 2020.09.09
C# paiza 80 - 예외처리1  (0) 2020.05.23
C# paiza 78 - 화상이미지 출력  (0) 2020.05.23
C# paiza 77 - 딕셔너리 루프  (0) 2020.05.23
C# paiza 76 - 딕셔너리 활용  (0) 2020.05.23

설정

트랙백

댓글

728x90
SMALL

////

// RPGのアイテム一を再現しよう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        //화상용 딕셔너리 아이템도

        //

       

        var itemImages = new Dictionary<string, string>();

        itemImages.Add("", "http://paiza.jp/learning/images/sword.png");

        itemImages.Add("", "http://paiza.jp/learning/images/shield.png");

        itemImages.Add("回復", "http://paiza.jp/learning/images/potion.png");

        itemImages.Add("クリスタル", "http://paiza.jp/learning/images/crystal.png");

       

        string[] items = { "クリスタル", "", "", "回復", "回復", "回復" };

   foreach(var item in items)

   {

       Console.WriteLine("<img src='" + itemImages[item] + "'>");

       Console.WriteLine(item);

       Console.WriteLine("<br>");

   }

   //아이템의 이미지 출력

   //아이템 리스트가 출력

 

    }

}

////

 

 

//////////////

 

///////////////화상이미지 출력

//연습1

// RPGのアイテム一を再現しよう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        var itemImages = new Dictionary<string, string>();

        itemImages.Add("", "http://paiza.jp/learning/images/sword.png");

        itemImages.Add("", "http://paiza.jp/learning/images/shield.png");

        itemImages.Add("回復", "http://paiza.jp/learning/images/potion.png");

        itemImages.Add("クリスタル", "http://paiza.jp/learning/images/crystal.png");

 

        string[] items = { "", "", "回復", "クリスタル" };

 

        // 像のURLを出力する

        foreach (var item in items)

        {

            Console.WriteLine("<img src'" + itemImages[item] + "'>");

           // Console.WriteLine("<br>");

        }

    }

}

//////////////

 

728x90

'프로그래밍' 카테고리의 다른 글

C# paiza 80 - 예외처리1  (0) 2020.05.23
C# paiza 79 - RPG 아이템 일람 재현  (0) 2020.05.23
C# paiza 77 - 딕셔너리 루프  (0) 2020.05.23
C# paiza 76 - 딕셔너리 활용  (0) 2020.05.23
C# paiza 75 - 딕셔너리 조작  (0) 2020.05.22

설정

트랙백

댓글

728x90
SMALL

//////

// Dictionaryをルプで理しよう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        var enemyDictionary = new Dictionary<string,string>();

        enemyDictionary.Add("ザコ","スライム");

        enemyDictionary.Add("中ボス", "ドラゴン");

        enemyDictionary.Add("ラスボス", "魔王");

 

        Console.WriteLine(enemyDictionary["ザコ"]);

        foreach(var enemy in enemyDictionary)

        {

            Console.WriteLine(enemy.Key + "" + enemy.Value + "が現れた!");

        }

        //key value가 대입된다.

        //key는 자코 중간보소, 라스보스

        //value는 뒤에 있는 슬라임, 드래곤, 마왕이 대입된다.

    }

}

/////////

////

 

// Dictionaryをルプで理しよ

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        var enemyDictionary = new Dictionary<string, string>();

        enemyDictionary.Add("ザコ", "スライム");

        enemyDictionary.Add("中ボス", "ドラゴン");

        enemyDictionary.Add("ラスボス", "魔王");

 

        // Dictionaryをルプで呼び出してください

foreach(var enemy in enemyDictionary)

{

        Console.WriteLine(enemy.Key + "" + enemy.Value + "が現れた");

}

    }

}

 

 

///////////////

////////

///

// Dictionaryをルプで理しよう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        var members = new Dictionary<string, string>();

        members.Add("", "つばめ");

        members.Add("六村", "リオ");

        members.Add("霧島", "京子");

 

        // Dictionaryをルプで呼び出してください

        foreach(KeyValuePair<string,string> enemy in members)

        {

           

            Console.WriteLine(enemy.Key + "さんの名前は" + enemy.Value + "です");

           

        }

       

       

    }

}

//////

/////////////////////

1. 아이템의 화상과 아이템의 이름을 표시한다.

2. 같은 아이템을 복수 표시한다.

3. 아이템의 정렬순을 관리한다.

4. 같은 아이템의 화상 파일은 하나를 공유한다.

딕셔너리와 배열을 組み合わせる必要があります。

아이템의 管理する 배열

나라비쥰에 번호, 아이템명에 아이템의 이름

화상용 딕셔너리 itemImages

Ex) 검이면 > sword.png 파일을 화상 파일로 읽어옴.

방패() > 방해 사진

Items[0] > 크리스탈 itemImages[items[0]] > 크리스탈 사진

이러한 내용을 루프로 처리한다.

/////////////////////////////

728x90

'프로그래밍' 카테고리의 다른 글

C# paiza 79 - RPG 아이템 일람 재현  (0) 2020.05.23
C# paiza 78 - 화상이미지 출력  (0) 2020.05.23
C# paiza 76 - 딕셔너리 활용  (0) 2020.05.23
C# paiza 75 - 딕셔너리 조작  (0) 2020.05.22
C# paiza 74 - 딕셔너리2  (0) 2020.05.22

설정

트랙백

댓글

728x90
SMALL

////////////////

/////

// Dictionaryから特定のキとバリュを削除してよう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        var enemyDictionary = new Dictionary<String, String>();

        enemyDictionary.Add("ザコ", "スライム");

        enemyDictionary.Add("中ボス", "ドラゴン");

        enemyDictionary.Add("ラスボス", "魔王");

 

        // 「ラスボス」キのペアを削除

         enemyDictionary.Remove("ラスボス");

        Console.WriteLine(enemyDictionary.Count);

    }

}

 

////////////

 

 

 

/////////

// Dictionaryをルプで理しよう

using System;

using System.Collections.Generic;

 

class Lesson09

{

    public static void Main()

    {

        var enemyDictionary = new Dictionary<string,string>();

        enemyDictionary.Add("ザコ","スライム");

        enemyDictionary.Add("中ボス", "ドラゴン");

        enemyDictionary.Add("ラスボス", "魔王");

 

        Console.WriteLine(enemyDictionary["ザコ"]);

        foreach(KeyValuePair<string,string> enemy in enemyDictionary)

        {

            Console.WriteLine(enemy.Key + "" + enemy.Value + "が現れた!");

        }

        //key value가 대입된다.

        //key는 자코 중간보소, 라스보스

        //value는 뒤에 있는 슬라임, 드래곤, 마왕이 대입된다.

    }

}

///////////////

 

/////

/////////////

728x90

'프로그래밍' 카테고리의 다른 글

C# paiza 78 - 화상이미지 출력  (0) 2020.05.23
C# paiza 77 - 딕셔너리 루프  (0) 2020.05.23
C# paiza 75 - 딕셔너리 조작  (0) 2020.05.22
C# paiza 74 - 딕셔너리2  (0) 2020.05.22
C# paiza 73 - 딕셔너리(Dictionary)1  (0) 2020.05.22

설정

트랙백

댓글