블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28

Category

Recent Post

Recent Comment

Archive

'.Net Project/.Net C#'에 해당되는 글 69

  1. 2009.08.17 81장 명령인수갯수
  2. 2009.08.10 34. Sort 선택정렬 Ex)
  3. 2009.08.10 33장 1~100까지 합중 3의 배수 그리고 4의 배수의 합
  4. 2009.08.10 32장 알고리즘(선택정렬)
2009. 8. 17. 13:28 .Net Project/.Net C#
반응형


실행화면 )


실행하는 방법에 대한 정의 )


//명령줄 인수(Command Line Prompt) :
// dir c:\ 식으로 명령어 exe 1 ~ 뒤에 따라오는 문자열
//1부터 100까지 3의 배수의 합을 구하는 프로그램
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 명령줄인수
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length<3)
            {
                Console.WriteLine("명령줄인수는 3개 이상 필요합니다");
                return;
               
            }
            int first = Convert.ToInt32(args[0]);
            int second = Int32.Parse(args[1]);
            int num = Convert.ToInt32 (args[2]);
            int sum = 0;
            for (int i = first ; i < second; i++)
            {
                if (i%num == 0)
                {
                    sum += i;
                   
                }
               
            }
            Console.WriteLine("{0} ~ {1}까지 {2}의 배수 합은 :
                                         {3}",first,second,num,sum);
        }
    }
}

반응형
posted by Magic_kit
2009. 8. 10. 18:55 .Net Project/.Net C#
반응형

using System;

public class sort
{
    public static void Main(string[] args)
    {
        int[] data = { 3, 2, 1, 5, 4 };
        int temp = 0;

        for (int i = 0; i < data.Length-1; i++)    // 기준 숫자
        {
            for (int j = i + 1; j < data.Length; j++)   // 기준 숫자와 비교될 숫자들
            {
                if (data[i] < data[j])    // 기준숫자가 작을 경우
                {
                    temp = data[i];                             
                    data[i] = data[j];    // 서로 자리를 바꿈
                    data[j] = temp;                                
                }
            }
        }

        for (int i = 0; i < data.Length; i++)
        {
            Console.Write("{0} ", data[i]);
        }
        Console.WriteLine();
    }
}
반응형
posted by Magic_kit
2009. 8. 10. 18:54 .Net Project/.Net C#
반응형

using System;

public class sum
{
    public static void Main(string[] args)
    {
        int sum = 0;

        for (int i = 1; i <= 100; i++)              // 1~100 까지의 숫자 중
        {
            if (i % 3 == 0 && i % 4 == 0)       // 3의 배수 그리고 4의 배수까지 

            {
                sum += i;                            // sum에 i를 가산한다.
            }
        }
        Console.WriteLine("{0}", sum);
    }
}

반응형

'.Net Project > .Net C#' 카테고리의 다른 글

81장 명령인수갯수  (0) 2009.08.17
34. Sort 선택정렬 Ex)  (0) 2009.08.10
32장 알고리즘(선택정렬)  (0) 2009.08.10
31장 알고리즘(순위)  (0) 2009.08.10
31장 StopWatch  (0) 2009.08.10
posted by Magic_kit
2009. 8. 10. 18:53 .Net Project/.Net C#
반응형

// Sort(정렬) : 순서대로 정렬시키는 알고리즘
// Ascending (오름차순) : 1,2,3 ABC 순
// Descening (내림차순) : 3,2,1, 다나가 순
// 종류 : 선택정렬, 버블정렬, 퀵정렬, 삽입, 기수, 등


using System;

public class 선택정렬
{
    public static void Main(string[] args)
    {
        int[] data = { 2, 4, 3, 7, 6, 1, 5 }; //배열선언
        int temp = 0; //선언과 동시에 초기화

        for (int i = 0; i < data.Length; i++)
        {
            for (int j = 0; j < data.Length; j++)
            {
                if (data[i] < data[j])
                {
                    temp = data[i];                  
                    data[i] = data[j];   // data 를 서로 바꿈
                    data[j] = temp;                  
                }
            }
            ShowArray(data);
        }

        for (int i = 0; i < data.Length; i++) //배열의 길이만큼 data[i] 값을 받아
        {
            Console.Write("{0}", data[i]); //출력
        }
        Console.WriteLine();
    }
    //배열 생성후 호출하는 방식으로 출력
    public static void ShowArray(int[] data)
    {
        for (int i = 0; i < data.Length; i++)
        {
            Console.Write("{0}", data[i]);
        }
        Console.WriteLine();
    }
}

반응형

'.Net Project > .Net C#' 카테고리의 다른 글

34. Sort 선택정렬 Ex)  (0) 2009.08.10
33장 1~100까지 합중 3의 배수 그리고 4의 배수의 합  (0) 2009.08.10
31장 알고리즘(순위)  (0) 2009.08.10
31장 StopWatch  (0) 2009.08.10
30장 Random Class(랜덤 클래스)  (0) 2009.08.10
posted by Magic_kit