336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

환경 : 

visual studio 2019

 

Source code : _003.ph

print('Hello python')_string = 'string Test'
string_name = 'junmoyo'
StringName='준모요'
cnt = 1
Cnt = 4

print( '_string : ' + _string )
print( 'string_name : ' + string_name )
print( 'StringName : ' + StringName)
print('cnt : %d'%cnt)
print('Cnt : %d'%Cnt)

Result

'Etc > Python' 카테고리의 다른 글

006 변수  (0) 2021.01.13
005 주석  (0) 2021.01.13
004  (0) 2021.01.13
002  (0) 2021.01.12
001 Hello python  (0) 2021.01.12
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

환경 : 

visual studio 2019

 

Source code : _002.ph

print('Hello python')print('Hello')
a = 3
b = 4 
print( a + b )

Result

'Etc > Python' 카테고리의 다른 글

006 변수  (0) 2021.01.13
005 주석  (0) 2021.01.13
004  (0) 2021.01.13
003  (0) 2021.01.12
001 Hello python  (0) 2021.01.12
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

환경 : 

visual studio 2019

 

Source code : _001.ph

print('Hello python')

Result

'Etc > Python' 카테고리의 다른 글

006 변수  (0) 2021.01.13
005 주석  (0) 2021.01.13
004  (0) 2021.01.13
003  (0) 2021.01.12
002  (0) 2021.01.12
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

목표 : 004 프로그램을 기능을 발전시킨다.

 

소스코드 : 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{

    public enum Arithmetic
    {
        plus,
        minus,
        multiple,
        division
    }
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            this.Clear();
        }

        private double GetNum(string str)
        {
            double returnValue = 0;
            if(string.IsNullOrEmpty(str))
            {
                MessageBox.Show("공백 입니다, 숫자를 입력하세요");
                this.Clear();
                throw new Exception("공백 입니다, 숫자를 입력하세요");
            }

            try
            {
                returnValue = double.Parse(str);
            }
            catch
            {
                MessageBox.Show("숫자를 입력하세요");
                this.Clear();
                throw new Exception("숫자를 입력하세요");
            }

            return returnValue;
        }

        private double GetNum1()
        {
            return GetNum(this.textNum1.Text);
        }

        private double GetNum2()
        {
            return GetNum(this.textNum2.Text);
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            double num1 = GetNum1();
            double num2 = GetNum2();
            double num = Operate(num1, num2, Arithmetic.plus);

            this.textResult.Text = num.ToString();
            this.lbResult.Text = "+";
        }
        private void btnMinus_Click(object sender, EventArgs e)
        {
            double num1 = GetNum1();
            double num2 = GetNum2();
            double num = Operate(num1, num2, Arithmetic.minus);

            this.textResult.Text = num.ToString();
            this.lbResult.Text = "-";
        }

        private void btnMul_Click(object sender, EventArgs e)
        {
            double num1 = GetNum1();
            double num2 = GetNum2();
            double num = Operate(num1, num2, Arithmetic.multiple);

            this.textResult.Text = num.ToString();
            this.lbResult.Text = "*";
        }

        private void btnDivision_Click(object sender, EventArgs e)
        {
            double num1 = GetNum1();
            double num2 = GetNum2();
            double num = Operate(num1, num2, Arithmetic.division);

            this.textResult.Text = num.ToString();
            this.lbResult.Text = "/";
        }
        private void btnClear_Click(object sender, EventArgs e)
        {
            this.Clear();
        }

        private void Clear()
        {
            this.textNum1.Text = "";
            this.textNum2.Text = "";
            this.textResult.Text = "";
            this.lbResult.Text = "Ready";
        }

        private double Operate(double num1, double num2, Arithmetic ari)
        {
            double returnValue = 0.0;

            switch(ari)
            {
                case Arithmetic.plus:
                    returnValue = num1 + num2;
                    break;
                case Arithmetic.minus:
                    returnValue = num1 - num2;
                    break;
                case Arithmetic.multiple:
                    returnValue = num1 * num2;
                    break;
                case Arithmetic.division:                    
                    returnValue = num1 / num2;
                    break;
            }

            return returnValue;
        }


    }
}

 

결과

'Programing C# > C# 200' 카테고리의 다른 글

003 C# 윈도우 프로그래밍  (0) 2020.01.06
002 C# 윈도우 프로그래밍  (0) 2020.01.03
001 C# 프로그래밍 시작하기.  (0) 2019.04.19
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

목표: 003 프로젝트에 예외를 처리 한다.

 

소스코드 : 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{

    public enum Arithmetic
    {
        plus,
        minus,
        multiple,
        divison
    }
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            this.Clear();
        }

        private double GetNum(string str)
        {
            double returnValue = 0;
            if(string.IsNullOrEmpty(str))
            {
                MessageBox.Show("공백 입니다, 숫자를 입력하세요");
                this.Clear();
                throw new Exception("공백 입니다, 숫자를 입력하세요");
            }

            try
            {
                returnValue = double.Parse(str);
            }
            catch
            {
                MessageBox.Show("숫자를 입력하세요");
                this.Clear();
                throw new Exception("숫자를 입력하세요");
            }

            return returnValue;
        }

        private double GetNum1()
        {
            return GetNum(this.textNum1.Text);
        }

        private double GetNum2()
        {
            return GetNum(this.textNum2.Text);
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            double num1 = GetNum1();
            double num2 = GetNum2();
            double num = Operate(num1, num2, Arithmetic.plus);

            this.textResult.Text = num.ToString();
            this.lbResult.Text = "+";
        }
        private void btnClear_Click(object sender, EventArgs e)
        {
            this.Clear();
        }

        private void Clear()
        {
            this.textNum1.Text = "";
            this.textNum2.Text = "";
            this.textResult.Text = "";
            this.lbResult.Text = "Ready";
        }

        private double Operate(double num1, double num2, Arithmetic ari)
        {
            double returnValue = 0.0;

            switch(ari)
            {
                case Arithmetic.plus:
                    returnValue = num1 + num2;
                    break;
                case Arithmetic.minus:
                    returnValue = num1 - num2;
                    break;
                case Arithmetic.multiple:
                    returnValue = num1 * num2;
                    break;
                case Arithmetic.divison:                    
                    returnValue = num1 / num2;
                    break;
            }

            return returnValue;
        }
    }
}

 

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

목표 :

002의 소스코드에 메서드를 만들어 보자

 

소스코드:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{

    public enum Arithmetic
    {
        plus,
        minus,
        multiple,
        divison
    }
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            this.Clear();
        }
        private double GetNum1()
        {
            return double.Parse(this.textNum1.Text);
        }

        private double GetNum2()
        {
            return double.Parse(this.textNum2.Text);
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            double num1 = GetNum1();
            double num2 = GetNum2();
            double num = Operate(num1, num2, Arithmetic.plus);

            this.textResult.Text = num.ToString();
            this.lbResult.Text = "+";
        }
        private void btnClear_Click(object sender, EventArgs e)
        {
            this.Clear();
        }

        private void Clear()
        {
            this.textNum1.Text = "";
            this.textNum2.Text = "";
            this.textResult.Text = "";
            this.lbResult.Text = "Ready";
        }

        private double Operate(double num1, double num2, Arithmetic ari)
        {
            double returnValue = 0.0;

            switch(ari)
            {
                case Arithmetic.plus:
                    returnValue = num1 + num2;
                    break;
                case Arithmetic.minus:
                    returnValue = num1 - num2;
                    break;
                case Arithmetic.multiple:
                    returnValue = num1 * num2;
                    break;
                case Arithmetic.divison:                    
                    returnValue = num1 / num2;
                    break;
            }

            return returnValue;
        }
    }
}

'Programing C# > C# 200' 카테고리의 다른 글

005 C# 윈도우 프로그래밍 발전  (0) 2020.01.08
002 C# 윈도우 프로그래밍  (0) 2020.01.03
001 C# 프로그래밍 시작하기.  (0) 2019.04.19
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

목표 :

mini 계산기를 만들어 본다.

 

소스코드 : 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            this.textNum1.Text = "";
            this.textNum2.Text = "";
            this.textResult.Text = "";
            this.lbResult.Text = "Ready";
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            double num1 = double.Parse(this.textNum1.Text);
            double num2 = double.Parse(this.textNum2.Text);
            double num = num1 + num2;
            this.textResult.Text = num.ToString();
            this.lbResult.Text = "+";
        }
        private void btnClear_Click(object sender, EventArgs e)
        {
            this.textNum1.Text = "";
            this.textNum2.Text = "";
            this.textResult.Text = "";
            this.lbResult.Text = "Ready";
        }
    }
}

 

결과 :

'Programing C# > C# 200' 카테고리의 다른 글

005 C# 윈도우 프로그래밍 발전  (0) 2020.01.08
003 C# 윈도우 프로그래밍  (0) 2020.01.06
001 C# 프로그래밍 시작하기.  (0) 2019.04.19
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

개념 정리 : 

다차원 배열이란 논리적으로 두 개 이상의 차원 가진 배열을 말합니다.

 

example 

int [다차원의 갯수 -1 을  , 로 표기함] value = new int [요소의 갯수]

 

2차원 배열

int [ , ] value2 = new int [ 3, 4 ]; // 3 개의 요소를 가지고 첫요소에는다시 4개 만큼 요소가 있는 배열 총 12개의 요소를가진다.

 

3차원 배열

int [ , , ]  value3 = new int [ 2, 3, 4 ]; // 2개의 요소를 가지고 그요소안에 3개씩 나눠 지고 또 다시 3개중 1개 요소는 4개의 요소를 가진다. 총 요소는 2 * 3 * 4 이므로 24 개가 된다.

 

4차원 배열

int [ , , , ] valuer4 = new int [ 2, 3, 4, 5 ]; //첫 요소는 2개를 가지고 그요소는 각자 3개의 공간을 가지고 다시 그요소 하나는 4개의 공간을 가지게되며 또 다시 하나의 요소는 5개의 공간을 가지게 된다. 총요소의 갯수는 2*3*4*5 이므로 120개의 요소를 가지게 된다.

 

 

다차원 배열에 대한 대입, 초기화, 참조

 

source code  example : 초기화 대입

 

int [ , ] value = {

{ 20, 30},

{ 22, 33}

};

 

풀이

value 배열을 선언하는데 값의 구조가 2 차원 배열이고 첫 번째 요소는 20, 30의 요소 2개를 얻었고 두번째 요소는 22, 33을 얻었으므로 2* 2 인 2차원 배열이다.

 

source code example : 참조 

 

Console.WriteLine ( value[ 1, 0 ] );

 

예상 값 : 22

 

풀이 

배열은 첫요소는 0부터 시작하고 앞서 2 * 2 이므로  접금할 수 있는 요소는 

value[ 0, 0 ];

value[ 0, 1 ];

value[ 1, 0 ];

value [ 1, 1];

되겠다.

 

source code

 

 

번외) 이게 공부 하려고 하는것은 맞으나 이렇게 하는게 의미 있는지 스스로 의문이 된다.

다른 문법위주로 공부 해야되지 않을까 하고 고민도 하지만 결국엔 자만해서 놓치는 부분이 있지 않을까 하는 높아심에 그냥 처음 부터 더듬고 가기로했다...

 

 

 

 

 

 

'Programing C# > C# Basic grammar' 카테고리의 다른 글

05 배열  (0) 2018.11.06
04 문자와 문자열  (0) 2018.02.24
03 기본변수들 출력  (0) 2018.02.19
02 기본 변수 출력  (0) 2018.02.18
01 Hello World  (0) 2018.02.18
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

1. 목표 :

기본 C# 프로그래밍을 작성하여 보자.

 

2. 소스코드 :

Program.cs

using System;// 기본 인클루드 개념
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;
// using System.Threading.Tasks;

namespace Com._001.mochi
{
    class mochi_001
    {
        static void Main(string[] args)
        {
            Console.WriteLine("두수를 입력하면 덧셈을 해드립니다.");
            // Console.WriteLine 은 자동 개행이 이뤄지는 함수이다.

            Console.Write("첫 번째 : "); 
            // Consle.Write은 자동 개행이 이뤄지는 함수가 아니다.

            int nFirst = int.Parse(Console.ReadLine()); 
            // int는 자료형이며 클래스다. Console.ReadLine으로 입력받은 값을 int.Parse로
            // 읽어들인 string 을 integer 로 변환하고 그값을 nFirst에 복사한다.

            Console.Write("두 번째 : ");

            int nSecond = int.Parse(Console.ReadLine());

            Console.WriteLine("{0} + {1} = {2}",nFirst, nSecond, (nFirst + nSecond));
            // Console.WriteLine의 기능으로 {}중괄호 안에 내용의 순서를 정할수 있다.
            // 예를들어 Console.WriteLine("{2} = {1} + {0}", nFirst, nSecond, (nFirst + nSecond));
            // 라고 할 경우 3 = 2 + 1과 같은 결과를 얻을 수 있다.

            Console.WriteLine("{2} = {1} + {0}", nFirst, nSecond, (nFirst + nSecond));
        }
    }
}

3. 결과

 

 

먹고 살려면 해야지 cpp로 먹고 살긴 힘들듯하당...

정말 개발자로 먹고 살려면 한가지 언어로는 진심 힘들다.

'Programing C# > C# 200' 카테고리의 다른 글

005 C# 윈도우 프로그래밍 발전  (0) 2020.01.08
003 C# 윈도우 프로그래밍  (0) 2020.01.06
002 C# 윈도우 프로그래밍  (0) 2020.01.03
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

개념 : 


1. 원형 double atan2(double y, double x);



소스코드:


#include<stdio.h>

#include<math.h>


int main(void)

{

const double PI = 3.141592653;

//double dDegree = 0.0;

double dRadian = 0.0;

double dResultATan = 0.0;


//dDegree = 45.0f;


double dX = 1.3;

double dY = 1.9;


dRadian = (PI / 180) * 45;


dResultATan = atan2(dY, dX);


printf("X : %g, Y: %g \n", dX, dY);

printf("atan : %f\n", dResultATan);


return 0;

}


/// 아크 탄제트를 구하는 함수.



결과:




+ Recent posts