일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- c#
- 백준
- 해시구현
- 백준 17779
- 해시 구현
- 별 찍기 10
- 풀이
- 시간 복잡도
- 자료구조
- 백준 17822
- 게리멘더링2
- 백준 5397
- 구현
- 5397
- dfs
- 백준 17471
- 원판 돌리기
- C/C++ 구현
- qorwns
- 1764
- 버킷 정렬
- 백준 1406
- AVL 시간 복잡도
- ㅣ풀이
- heap
- 백준 1158
- 스택의 특징
- Stack 이란
- 조세퍼스 순열
- 백준 2447
- Today
- Total
홍시홍의 프로그래밍
[C#] 간단한 Class 활용(제곱, 합 메서드 만들기) 본문
test 클라스 안에
power라는 제곱을 구하는 메서드와
sumall이라는 숫자의 합을 구하는 메서드
class Test
{
public int Power( int input)
{
return input * input;
}
public int Power(int input, int count)
{
int tot=1;
for( int i = 0; i < count; i++)
{
tot *= input;
}
return tot;
}
public int Sumall(int end)
{
int tot = 0;
for (int i = 0; i < end; i++)
{
tot += i;
}
return tot;
}
public int Sumall(int start, int end)
{
int tot = 0;
for (int i = start; i < end; i++)
{
tot += i;
}
return tot;
}
}
class Program
{
static void Main(string[] args)
{
Test ad = new Test();
Console.WriteLine(ad.Power(3));
Console.WriteLine(ad.Power(3, 4));
Console.WriteLine(ad.Sumall(3));
Console.WriteLine(ad.Sumall(3, 12));
}
}
실행결과
'C#' 카테고리의 다른 글
[C#]타이머를 활용한 간단한 자동차 경기(윈도우 폼) (0) | 2017.04.05 |
---|---|
[C#] 윈도우폼에서 간단한 타이머 활용 (0) | 2017.04.05 |
[C#] 윈도우 폼을 활용한 바둑판 만들기 (0) | 2017.04.04 |
[C#] 1~100 까지 합 구하기 (0) | 2017.04.04 |
[C#] 랜덤 숫자 만들기, 맞추기 (0) | 2017.04.04 |