1 / 49

C# 스터디 ( 가칭 )-1

C# 스터디 ( 가칭 )-1. UPnL 장준영. 일단 켜봅시다. Microsoft visual studio 2010. 켜 는 동안. 하지만. 버튼을 클릭해도. 아무 일도 일어나지 않습니다. 기본 문법. 기본 문법을 알아야 뭐라도 만들 수 있다 !. 기본 문법. 기본 문법을 알아야 뭐라도 만들 수 있다 !. 오늘 배울 것. 변수 연산자 제어문 ( 배열 ). 오늘 만들 것. 완전수 찾기. 변수. int , bool , double char, byte, short, long, float

Download Presentation

C# 스터디 ( 가칭 )-1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C# 스터디(가칭)-1 UPnL장준영

  2. 일단 켜봅시다 Microsoft visual studio 2010

  3. 켜는 동안

  4. 하지만

  5. 버튼을 클릭해도

  6. 아무 일도일어나지 않습니다.

  7. 기본 문법 • 기본 문법을 알아야 • 뭐라도 만들 수 있다!

  8. 기본 문법 • 기본 문법을 알아야 • 뭐라도 만들 수 있다!

  9. 오늘 배울 것 • 변수 • 연산자 • 제어문 • (배열)

  10. 오늘 만들 것 • 완전수 찾기

  11. 변수 int, bool, double char, byte, short, long, float uint

  12. Hello World! Console.WriteLine()

  13. Console.WriteLine(“Hello World”);

  14. Hello World! Console.WriteLine()

  15. 변수 선언 • int a; // 정수 • bool b; // 참 또는 거짓 • double c; // 실수 • string s; // 문자열

  16. 변수에대입 • int a = 30; // 정수 • bool b = true; // 참 또는 거짓 • double c = 2.3; // 실수 • string s = “유피넬”;// 문자열

  17. 또는 • double c; • c = 2.3; • string s; • s = “유피넬”; • int a; • a = 30; • bool b; • b = true;

  18. 출력 • int a = 30; // 정수 • Console.WriteLine(a); • string s = “유피넬”;// 문자열 • Console.WriteLine(s); • 등등…

  19. 연산자 +-*/%=<>!&^~

  20. + - * / % • int a = 8; • int b = 3; • Console.WriteLine(a + b); • Console.WriteLine(a - b); • Console.WriteLine(a * b); • Console.WriteLine(a / b); • Console.WriteLine(a % b);

  21. + - * / % • int a = 8; • int b = 3; • Console.WriteLine(a + b); // 11 • Console.WriteLine(a - b); // 5 • Console.WriteLine(a * b); // 24 • Console.WriteLine(a / b); // 2 • Console.WriteLine(a % b); // 2

  22. 문자열 + • string a = “Hello ” • string b = “UPnL!” • Console.WriteLine(a + b); • Console.WriteLine(b + a); • Console.WriteLine(a + “World!”);

  23. 문자열 + • string a = “Hello ” • string b = “UPnL!” • Console.WriteLine(a + b); // Hello UPnL! • Console.WriteLine(b + a); // UPnL!Hello • Console.WriteLine(a + “World!”);

  24. 비교(==, >, <, !=) • int a = 10; • int b = 15; • Console.WriteLine(a == b); // False • Console.WriteLine(a != b); // True • Console.WriteLine(a <b); // True • Console.WriteLine(a >b); // False

  25. 비교(==, >, <, !=) • 결과 값은 bool이다. • int a = 10; • int b = 15; • bool c = (a == b);

  26. 대입(=, +=) • int a = 10; // 10 • a += 10; // 20 • 마찬가지로 -=, *=, /=, %= 등이 있음

  27. 증감(++, --) • int a = 10; // 10 • a++; // 11 • a--; // 10 • --a; // 9 • ++a; // 10

  28. 제어문 If, for, while do~while, foreach

  29. if if(true) { Console.WriteLine(“맞아요”); }

  30. if int a = 5; int b = 10; if(a == b) { Console.WriteLine(“같아요”); }

  31. if~else if(a == b) { Console.WriteLine(“같아요”); } else { Console.WriteLine(“달라요”); }

  32. if~elseif~else if(a == b) { Console.WriteLine(“같아요”); } else if(a < b) { Console.WriteLine(“작아요”); } else { Console.WriteLine(“커요”); }

  33. for for(inti = 0; i < 10; i++) { Console.WriteLine(i); } // 0부터 9까지 출력

  34. for와 if for(inti = 0; i < 10; i++) { if(i % 2 == 0) { Console.WriteLine(i); } } // 0부터 9까지 짝수를 출력

  35. while inti = 0; while(i < 10) { Console.WriteLine(i); i++; } // 0부터 9까지 출력

  36. break, continue inti = 0; while(i < 10) { if(i == 5) break; Console.WriteLine(i); i++; } // 0부터 4까지 출력

  37. break, continue inti = 0; while(i < 10) { if(i == 5) continue; Console.WriteLine(i); i++; } // 0부터 4, 6부터 9까지 출력

  38. 합 구하기 int sum = 0; for(inti = 0; i < 10; i++) { sum += i; } Console.WriteLine(sum); // 0부터 9까지 합을 출력(45)

  39. 오늘 만들 것 • 완전수 찾기

  40. 오늘 만들 것 • 1부터 10000까지 수 중 완전수를 찾으세요. • 완전수: 약수의 합이 자기 자신의 2배인 수 • 6 * 2 = 1 + 2 + 3 + 6 • 28 * 2 = 1 + 2 + 4 + 7 + 14 + 28

  41. 오늘 만들 것 for(int I = 1; I <= 10000; i++) { for(int j = 1; j <= i; j++) { if(어떠하면) 숫자를 더한다. } }

  42. 오늘 만들 것 • 완전수 찾기

  43. 오늘 만들 것 for(int I = 1; I <= 10000; i++) { for(int j = 1; j <= i; j++) { if(어떠하면) 숫자를 더한다. } }

  44. 배열 inta = new int[10];

  45. 배열 • inta = new int[10];

More Related