E D R , A S I H C RSS

BackLinks search for "i"

BackLinks of i


Search BackLinks only
Display context of search results
Case-sensitive searching
  • 1R/2016_09_21
          * [https://www.acmicpc.net/problem/9663|N-Queen]
         #include<iostream>
         using namespace std;
         int N = 0;
         int ans = 0;
         void putQueen(int dep, int loca[15], int visit){
          if(dep == -1){
          for(int i = 0; i < N; i++){
          if(!(visit & 1 << i)){
          for(int k = dep + 1; k<N; k++){
          if(loca[k] == i + k - dep || loca[k] == i - k + dep){
          if(checker){
          loca[dep] = i;
          putQueen(dep-1, loca, visit + (1 << i));
         int main(){
          cin>> N;
          int loca[15] = { 0, };
         #include <iostream>
         #include <vector>
         int cnt=0,n;
  • 1R/2016_09_22
          * [https://www.acmicpc.net/problem/2636|치즈]
         #include<iostream>
         using namespace std;
         int arr[100][100] = {0,};
         int visit[100][100] = {0,};
         int X, Y, cNum = 0;
         int N, ans = 0;
         void check(int x, int y, int H){
          if(x <0 || y < 0 || x > X-1 || y > Y-1 || visit[x][y] == H){
          visit[x][y] = H;
          if(arr[x][y] == 1){
         int main(){
          cin>> X >> Y;
          for(int i = 0; i<X; i++){
          for(int j = 0; j<Y; j++){
          int tmp;
          if(tmp == 1){
          arr[i][j] = tmp;
          int H = 1;
          while(cNum){
  • 1R/2016_10_12
          * [https://www.acmicpc.net/problem/1003|피보나치 함수]
          * [https://www.acmicpc.net/problem/1149|RGB거리]
          * [https://www.acmicpc.net/problem/1912|연속합]
         #include<iostream>
         #include<utility>
         using namespace std;
         int arr[41][2] = { 0, };
         pair<int,int> search(int num){
          if(arr[num][0] + arr[num][1]){
          return make_pair(arr[num][0], arr[num][1]);
          pair<int,int> tmp1 = search(num-1);
          pair<int,int> tmp2 = search(num-2);
          arr[num][0] = tmp1.first + tmp2.first;
          return make_pair(arr[num][0], arr[num][1]);
         int main(){
          int T;
          cin>>T;
          while(T--){
          int n;
          cin>> n;
  • 1R/2016_10_13
          * [https://www.acmicpc.net/problem/1301|비즈 공예]
         #include<iostream>
         #include<cstring>
         using namespace std;
         long long int dp[12][12][12][12][12][6][6] = {0,};
         long long int arr[5] = {0,};
         long long int n;
         long long int search(long long int now[5], long long int p1, long long int p2){
          if(now[0] + now[1] + now[2] + now[3] + now[4] == 0){
          if(dp[now[0]][now[1]][now[2]][now[3]][now[4]][p1][p2] != -1){
          long long int ans = 0;
          for(long long int i = 0; i<n; i++){
          if(!now[i]){
          continue;
          if(p1 == i || p2 == i){
          continue;
          now[i]--;
          ans += search(now, p2,i);
          now[i]++;
         int main(){
  • AcceleratedC++/Chapter13
         = Chapter 13 Using inheritance and dynamic binding =
         == 13.1 Inheritance ==
         '''상속(inheritance)'''
         public:
          Core(std::istream&);
          std::string name() const;
          std::istream& read(std::istream&);
         private:
          std::istream& read_common(std::istream&);
          std::string n;
          double midterm, final;
         class Grad:public Core { // 구현(implementation)의 일부가 아닌 인터페이스(interface)의 일부로서 상속받는다는 것을 나타냄.
         public: // Core의 public요소를 그대로 public 요소로 받는다.
          Grad(std::istream&);
          std::istream& read(std::istream&);
         private:
          double thesis; // 논문관련 점수를 저장하는 멤버변수
         Grad 클래스는 Core로 부터 파생되었다(Derived from), 상속받았다(inherits from), 혹은 Core는 Grad의 base class 이다 라는 표현을 사용한다.
          === 13.1.1 보호정책(protection)에 대해서 다시 살펴보기 ===
          private 보호 레이블로 지정된 멤버는 그 클래스 자체, friend 함수를 통해서만 직접적으로 접근이 가능하다. 이 경우 상속된 클래스에서는 부모 클래스의 private 멤버로의 접근이 필요한데 이럴때 '''protected'''라는 키워드를 사용하면 좋다.
  • AcceleratedC++/Chapter5
         = Chapter 5 Using sequential containers and analyzing strings =
          * 여태까지 vector랑 string 갖고 잘 놀았다. 이제 이것들을 넘어서는 것을 살펴볼 것이다. 그러면서 라이브러리 사용법에 대해 더 깊게 이해하게 될것이다. 라이브러리는 자료구조?함수만을 제공해주는 것이 아니다. 튼튼한 아키텍쳐도 반영해준다. 마치 vector의 사용법을 알게 되면, 다른것도 쉽게 배울수 있는것처럼...
          == 5.1 Separating students into categories ==
         bool fgrade(const Student_info& s)
         vector<Student_info> extract_fails(vector<Student_info>& students)
          vector<Student_info> pass, fail;
          for(vector<Student_info>::size_type i = 0; i != students.size() ; ++i)
          if(fgrade(students[i]))
          fail.push_back(students[i]);
          pass.push_back(students[i]);
          return fail;
          * 참조로 넘어간 students의 점수를 모두 읽어들여서, 60 이하면 fail 벡터에, 아니면 pass 벡터에 넣은 다음, students 벡터를 pass벡터로 바꿔준다. 그리고 fail을 리턴해준다. 즉 students에는 f 아닌 학생만, 리턴된 vector에는 f 뜬 학생만 남아있게 되는 것이다. 뭔가 좀 삐리리하다. 더 쉬운 방법이 있을 듯하다.
          === 5.1.1 Erasing elements in place ===
          * 그렇다. 메모리 낭비가 있는 것이다. for루프가 끝날때에는 중복되는 두개의 벡터가 존재하는 것이다. 그래서 우리가 쓸 방법은 만약 f면 fail에 추가하고, f 아니면 그 자리에서 지우는 것이다. 반갑게도 이런 기능이 있다. 근데 졸라 느리다. 입력 데이터의 양이 커질수록 성능 저하는 급격하다. 벡터에서는 중간에 하나를 지우면, 메모리를 통째로 다시 할당하고, 지워주는 짓을 해야한다. O(n*n)의 시간이 필요한것으로 알고 있다. 벡터는 임의 접근이 가능한 대신, 중간 삽입이나 중간 삭제의 퍼포먼스를 포기한 것이다. 이제부터 여러가지 방법을 살펴볼 것이다.
         vector<Student_info> extract_fails(vector<Student_info>& students)
          vector<Student_info> fail;
          vector<Student_info>::size_type i = 0
          while(i != students.size()) {
          if(fgrade(students[i])) {
          fail.push_back(students[i]);
  • CNight2011/고한종
         [CNight2011]
         sorting이랑 스택큐? 인가 한다고 했었는데 이것도 결국 안함 ㅋ
         int arr[5];
         printf("%d",arr);
         arr[i] = *&(arr[0]+sizeof(int)*i);
         arr[i][j] *&(arr[0][0] sizeof(int)*i*j+sizeof(int)*i); -> 맞겠지여...?
          }nickname;
          사용할땐 nickname만 써주면 된다.
          }nickname;
         <stdlib.h> 을 선언한다.
          float* dia =(float*)malloc(sizeof(float)*10);
         10은 배열로 치면 dia[ 10]을한 셈이 된다.
         dia[ 10]이랑 다른점은.. dia[ 10]은 stack에 할당된다는것이 다른점이다.
         C언어에서 int a[ 2]={1,2} 선언후 printf("%d",a[2]); 같은 경우도 허용하므로 언제 터지는지 알 수가 없었다..
         암튼 그래서 횟수를 측정할 int i;를 만들고
         if(i%10==0)realloc(dia,sizeof(float)*10*k++);이라고 했다.
  • Code Race/2016/리바이
         #include <stdio.h>
         #include <stdbool.h>
         int main()
          printf("TEAM : 장용운 새싹 1 이길상 새싹 2 김남효\n");
         #include <stdio.h>
         #include <stdbool.h>
         #pragma warning (disable:4996)
         int main()
          int a[8];
          printf("TEAM : 장용운 새싹 1 이길상 새싹 2 김남효\n");
          while (1)
          for (int i = 0; i < 8; i++)
          scanf("%d", &a[i]);
          for (int i = 0; i < 8; i++)
          if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1)
          printf("%d ", a[i]);
          printf("\n");
         #include <stdio.h>
         #include <stdbool.h>
         #pragma warning (disable:4996)
  • IsBiggerSmarter?
         [http://online-judge.uva.es/p/v101/10131.html 원문보기]
         === About [IsBiggerSmarter?] ===
         어떤 사람들은 코끼리가 클수록 더 똑똑하다고 생각한다. 그런 생각이 틀렸다는 것을 증명하기 위해, 일련의 코끼리들을 분석해서 체중은 증가하는 순서로, IQ는 감소하는 순서로 된 가장 긴 시퀀스를 뽑아보자.
         === Input ===
         한 줄에 한 마리씩, 여러 코끼리에 대한 정보가 입력된다. 파일 종료 문자가 입력되면 입력이 끝난다. 각 코끼리에 대한 정보는 한 쌍의 정수로 입력되는데, 첫번째 정수는 체중을 킬로그램 단위로 나타낸 것이고, 두번째 정수는 IQ에 100을 곱한 값이다. 두 정수는 모두 1 이상 10,000 이하다. 최대 1,000 마리의 코끼리에 대한 정보가 입력될 수 있다. 체중이 같은 코끼리가 두 마리 이상 있을 수 있으며, IQ가 같은 코끼리가 두 마리 이상 있을 수도 있다. 그리고 체중과 IQ가 모두 똑같을 수도 있다.
         첫째 줄에는 찾아낸 코끼리 시퀀스의 길이를 나타내는 정수 n을 출력한다. 그 밑으로는 n줄에 걸쳐서 각 코끼리를 나타내는 양의 정수를 하나씩 출력한다. i번째 데이터 행으로 입력된 숫자들을 W[i], S[i]라고 표기해보자. 찾아낸 n마리의 코끼리의 시퀀스가 a[1], a[2], ... ,a[n] 이라면 다음과 같은 관계가 성립해야 한다.
         이런 관계가 만족되면서 n은 최대한 큰 값이어야 한다. 모든 부등호에는 등호는 포함되지 않는다. 즉 체중은 반드시 증가해야 하며(같으면 안됨), IQ는 감소해야 한다.(IQ도 같으면 안 됨). 조건이 맞으면 아무 답이나 출력해도 된다.
         === Sample Input ===
         || [문보창] || C++ || . || [IsBiggerSmarter?/문보창] ||
         [문제분류] [AOI]
  • LUA_4
         >function foo()
         >>print("foo!!")
         >print(type(a)) -- a의 type을 알 수 있다.
         function
         [ function 함수명() end ] 형태로 함수를 만들 수 있습니다.
         > function sum(a,b)
         > print ("a+b=",sum(1,2))
         > function sum(...) -- 가변 매개변수를 받는다.
         >> for i = 1, #arg do sum = sum + arg[i] end
         > print ( sum(1,2,3,4,5) )
         > outside = 1
         > function scope()
         >> local inside = 2 -- inside는 local 에서만 쓸 수 있도록 선언한다.
         >> print (inside)
         > print(outside) -- outside 는 존재 해도 ...
         > print(inside) -- inside는 존재하지 않는다. nil 반환
         nil
         > function scope1()
         >> local inside = 1
         >> function scope2()
  • LUA_5
         > print( Hasht["a"] )
         > print( Hasht["b"] )
         > print ( HashT2.a )
         > Fruit = { "apple","orange","banana" }
         > print ( Fruit[1] )
         그렇기 때문에 테이블은 배열로도 사용 될 수 있습니다. 그럼 배열에 추가적으로 insert 하고 remove 해 보겠습니다.
         > Fruit[ #Fruit + 1 ] = "grape" -- Fruit 의 아이템 갯수를 얻어 + 1을 해서 마지막 첨자를 구해 값을 대입한다.
         > print( Fruit[4] )
         이렇게 귀찮게 추가를 할 수도 있지만, 간단히 table.insert(Fruit,"kiwi") 처럼 간단히 할 수도 있습니다. 삭제는 table.remove(Fruit,4) 로 4번째 아이템을 삭제 할 수 있습니다.
         > table.insert(Fruit,"mango")
         > print(Fruit[6])
         > table.remove(Fruit,6)
         > print(Fruit[6])
         nil
         > table.sort(Fruit)
         > for i = 1,#Fruit do print(Fruit[i]) end
         kiwi
         >function Car(name)
         >> local function Go()
         >> print( car_name .. " is running" )
  • MoreEffectiveC++/Basic
         ["MoreEffectiveC++"]
         = Basic =
         == Item 1: Distinguish between pointers and references. ==
          * Item 1: Pointer와 Reference구별해라.
          Pointers use the "*" and "->" operators, references use "." [[BR]]
          string& rs; // Reference(참조)가 초기화가 되지 않아서 에러
          string s("xyzzy"); // 이건 된다 신기하네
          string& rs = s;
         아직 string써본적 한번도 없다. 반성..
          void printDouble(const double& rd)
          void printDouble (const double* pd)
          if (pd){
          cout << *pd // pd가 null인지 검사 해야 한다. pointer니까.
         pointer의 유의 사항인 null에 관한 내용을 다시 알려준다.
          string s1("Nancy"); // 이제는 무슨 퀴즈 같다.
          string s2("Clancy");
          string& rs = s1;
          string* ps = &s1;
         사견: Call by Value 보다 Call by Reference와 Const의 조합을 선호하자. 저자의 Effective C++에 전반적으로 언급되어 있고, 프로그래밍을 해보니 괜찮은 편이었다. 단 return에서 말썽이 생기는데, 현재 내 생각은 return에 대해서 회의적이다. 그래서 나는 COM식 표현인 in, out 접두어를 사용해서 아예 인자를 넘겨서 관리한다. C++의 경우 return에 의해 객체를 Call by Reference하면 {} 를 벗어나는 셈이 되는데 어디서 파괴되는 것인가. 다 공부가 부족해서야 쩝 --;
          오해의 소지가 있도록 글을 적어 놨군요. in, out 접두어를 이용해서 reference로 넘길 인자들에서는 in에 한하여 reference, out은 pointer로 new, delete로 동적으로 관리하는것을 의도한 말이었습니다. 전에 프로젝트에 이런식의 프로그래밍을 적용 시켰는데, 함수 내부에서 포인터로 사용하는 것보다 in에 해당하는 객체 사용 코딩이 편하더군요. 그리고 말씀하신대로, MEC++ 전반에 지역객체로 생성한 Refernece문제에 관한 언급이 있는데, 이것의 관리가 C++의 가장 큰 벽으로 작용하는 것이 아닐까 생각이 됩니다. OOP 적이려면 반환을 객체로 해야 하는데, 이를 포인터로 넘기는 것은 원칙적으로 객체를 넘긴다고 볼수 없고, 해제 문제가 발생하며, reference로 넘기면 말씀하신데로, 해당 scope가 벗어나면 언어상의 lifetime이 끝난 것이므로 영역에 대한 메모리 접근을 OS에서 막을지도 모릅니다. 단, inline에 한하여는 이야기가 달라집니다. (inline의 코드 교체가 compiler에 의하여 결정되므로 이것도 역시 모호해 집니다.) 아예 COM에서는 OOP에서 벗어 나더라도, 범용적으로 쓰일수 있도록 C스펙의 함수와 같이 in, out 의 접두어와 해당 접두어는 pointer로 하는 규칙을 세워놓았지요. 이 설계가 C#에서 buil-in type의 scalar형에 해당하는 것까지 반영된 것이 인상적이 었습니다.(MS가 초기 .net세미나에서 이 때문에 String 연산 차이가 10~20배 정도 난다고 광고하고 다녔었는데, 지금 생각해 보면 다 부질없는 이야기 같습니다.) -상민
  • MoreEffectiveC++/Operator
         ["MoreEffectiveC++"]
         == Item 5: Be wary of user-defined conversion functions. ==
          * Item 5: 사용자 정의 형변환(conversion) 함수에 주의하라!
          * C++는 타입간의 암시적 type casting을 허용한다. 이건 C의 유산인데 예를 들자면 '''char'''과 '''int''' 에서 '''short'''과 '''double''' 들이 아무런 문제없이 바뀌어 진다. 그런데 C++는 이것 보다 한수 더떠서 type casting시에 자료를 잃어 버리게 되는 int에서 short과 dougle에서 char의 변환까지 허용한다.[[BR]]
          * C++에서는 크게 두가지 방식의 함수로 형변환을 컴파일러에게 수행 시키킨다:[[BR]] '''''single-argument constructors''''' 와 '''''implicit type conversion operators''''' 이 그것이다.
          * '''''single-argument constructors''''' 은 인자를 하나의 인자만으로 세팅될수 있는 생성자이다. 여기 두가지의 예를 보자
         public:
          Name( const string& s);
         class Rational {
         public:
          Rational( int numerator = 0, int denominator = 1);
          * '''''implicit type conversion operator''''' 은 클래스로 하여금 해당 타입으로 ''return'' 을 원할때 암시적인 변화를 지원하기 위한 operator이다. 아래는 double로의 형변환을 위한 것이다.
         class Rational{
         public:
         Rational r(1,2);
         Rational (1,2);
         cout << r; // should print "1/2"
         '''operator<<'''는 처음 Raional 이라는 형에 대한 자신의 대응을 찾지만 없고, 이번에는 r을 ''operator<<''가 처리할수 있는 형으로 변환시키려는 작업을 한다. 그러는 와중에 r은 double로 암시적 변환이 이루어 지고 결과 double 형으로 출력이 된다.[[BR]]
         class Raional{
         public:
  • OptimizeCompile
         === Basic of Compiler Optimization ===
         현재 프로세서의 속도는 [무어의 법칙]에 따라 극한으로 속도가 증가하고 있다. 이러한 상황에서는 예전처럼 [CPU] 의 속도 에 프로그램의 실행속도가 크게 영향 받지는 않으므로, 컴파일러의 최적화 작업도 더이상 연산(computation)을 줄이는 것 만이 목적이 되는 것이 아니라, 좀 더 메모리 계층구조를 효율적으로 사용하는 것에 관심이 기울여지게 된다.
          ''Local optimization 과 Global optimization.''
         프로그램(translation unit)은 진행방향이 분기에 의해 변하지 않는 부분의 집합인 basic block 들로 나눌 수 있는데 이 각각의 block 에 대하여 최적화 하는 것을 local optimization 이라 하고, 둘 이상의 block 에 대하여, 혹은 프로그램 전체를 총괄하는 부분에 대하여 최적화 하는 것을 global optimization 이라고 한다.
         ==== Reduction of computation ====
         실행 시간(run time) 중의 계산을 줄이는 것이 목적이다. 이 최적화는 '미리 컴파일 시간에 계산(precomputaion in compile time)' 할 수 있거나, '미리 계산된 값을 재사용(reuse a previously computated value)' 할 수 있는 상황에서 적용된다.
         '''Constant propagation'''
         PI = 3.14159;
         area = 2 * PI * radius;
         위와 같은 부분에서, PI 의 값이 중간에 변경되지 않는다면, 위의 코드는
         PI = 3.14159;
         area = 2 * 3.14159 * radius;
         ''' Constant folding'''
         PI = 3.14159;
         area = 6.28318 * radius;
         컴파일러는 constant propagation 과 constant folding 을 반복하여 수행한다. 각각 서로의 가능성을 만들어 줄 수 있으므로, 더이상 진행 할 수 없을 때까지 진행한다.
         ''' Copy propagation'''
         '''Common subexpression elimination'''
         ''' Partial redundancy analysis'''
         '''Removing loop invariant code'''
  • PythonForStatement
          for i in a:
          print i
          for d in a:
          print d
         비슷한 것을 찾자면 C++의 배열보다는 C++의 string 클래스, Java의 String 클래스와 비슷하다는 점을 알 수 있어. -- [Leonardong]
         for i in 'helloworld':print i,
         for i in [ 'h','e','l','l','o','w','o','r','l','d']:print i,
         for statement definition
         for_stmt ::= "for" target_list "in" expression_list ":" suite
          ["else" ":" suite]
         for 타겟객체리스트(target) in 시퀀스형(expression_list==sequence):
          식(expression)
         in 다음에 와야할 문은 시퀀스형 입니다.
         These represent finite ordered sets indexed by non-negative numbers. The built-in function len() returns the number of items of a sequence. When the length of a sequence is n, the index set contains the numbers 0, 1, ..., n-1. Item i of sequence a is selected by a[i].
         음수가 아닌수로 제한되어 있으며 순서가 매겨진 집합. 내장함수인 len()는 시퀀스의 아이템 갯수를 반환한다. 시퀀스의 길이라 n이면, 인덱스는 0..n-1 까지의 범위를 가진다. 시퀀스의 아이템 i는 a[i]로 선택된다.
         {{|There are six sequence types: strings, Unicode strings, lists, tuples, buffers, and xrange objects|}}
         내장형인 strings 도 시퀀스 형이며, {{{a[i]}}} 형태로 접근할수 있습니다. 따라서,
         for i in 'helloworld': print i,
         에서 i는 반복적으로 'h','e'... 을 반환하며
         위에 기술된대로 list형 역시 시퀀스 형이며, {{{a[i]}}} 형태로 접근할수 있습니다.
  • TAOCP/BasicConcepts
         = 1.1 Algorithms =
         == 알고리즘 E(유클리드의 알고리즘(Euclid's algorithm)) ==
         양의 정수 m과 n이 주어졌을때, 그것들의 최대공약수(greatest common divisor)
         Fig 1. 알고리즘 E의 순서도
         1) 유한성(Finiteness)
         2) 명확성(Definiteness)
         3) 입력(Input)
         5) 효율성(Effectiveness)
         계산적인 방법(computational method)을 4쌍의 (Q,I,Ω,f)로 형식을 갖춰 정의하자
         Q는 부분집합 I와 Ω를 포함하는 집합이다
         I : 입력
         집합 I의 원소 x의 입력은 계산수열, x0, x1, x2,..., 를 다음과 같이 정의한다
         I를 모든 쌍 (m,n)의 부분집합이라 하자.
         = 1.3. MIX =
         이 책의 수많은 부분에서 MIX언어가 등장한다. 따라서 독자는 이 절을 주의 깊게 공부해야 한다.
         == 1.3.1. Description of MIX ==
          * Words( Partitial fieslds of words포함)
          * Registers
          A, X register
          I register - rI1~rI6까지 있음.
  • TAOCP/InformationStructures
         = 2.2. Linear Lists =
         == 2.2.2. Sequential Allocation ==
         Sequential Allocation은 stack을 다루는데 편리하다.
          마지막 원소 빼기(setting Y equal to the top node and delete)
          ''새 원소 넣기(inserting an element at the rear of the queue)
          맨 앞 원소 빼기(removing the front node)
          F ← F + 1; Y ← X[F]; if F = R, then set F ← R ← 0''
         하지만 공간낭비가 무한할 수 있다.( F, R이 계속증가하기 때문이다.) 따라서 이런 문제(the problem of the queue overrunning memory)를 해결하려면, M개의 노드(X[1]...X[M])가 순환하도록 한다.
          ''if R = M then R ← 1, otherwise R ← R + 1; X[R] ← Y.
          if F = M then F ← 1, otherwise F ← F + 1; Y ← X[F].''
         하지만 리스트가 더 많으면 bottom이 움직일 수 있어야 한다.(we must allow the "bottom" elements of the lists to change therir positions.) MIX에서 I번째 한 WORD를 rA에 가져오는 코드는 다음과 같다.
          ''LD1 I ;I를 rI2에 넣는다.
          LDA *,1 ;여기에 I를 더한 주소로 가서 그 값을 rA에 넣는다.''
         n개의 스택이 있는 경우 i번째(1≤i≤n) 스택에 원소를 넣고 빼는 과정을 다음과 같이 적을 수 있다.
         여기서 i번째 스택에서 오버플로우가 생기면 메모리 재배치(repack memory)를 할 수 있다. 몇가지 방법이 있는데 지금부터 자세히 알아보자.
          i번째 스택에서 오버플로우가 생겼을 때''
          a) ''''위로 한칸씩 밀기(moving things up)'''
          i<k≤n인 k 가운데 TOP[k] < BASE[k+1]인 가장 '''작은''' k를 찾는다. 찾으면 TOP[k] ≥ L>BASE[i+1]인 L에 대해서 다음을 한다.
          그리고 마지막으로 i보다 크고 k보다 크지 않은 모든 BASE와 TOP을 하나씩 위로 민다.
          b) ''''아래로 한칸씩 밀기(moving things down)''' a)에 해당하는 k가 없을 경우
  • WOWAddOn/2011년프로젝트/초성퀴즈
         그래서 Programming in Lua라는 책을 도서관에서 빌려왔다. 아마 빌려온지 1주일은 됬겠지.
         Lua-Eclipse를 받아서 깔고. (LunarEclipse라는 것도 있단다)
         http://luaeclipse.luaforge.net/
         Eclipse에서 Java외의 다른것을 돌리려면 당연 인터프리터나 컴파일러를 설치해주어야 한다. 그래서 Lua를 설치하려했다. LuaProfiler나 LuaInterpreter를 설치해야한다는데 도통 영어를 못읽겠다 나의 무식함이 들어났다.
         에서 루아 Windows 인스톨러를 받아서 설치하게됬다.
         LuaForWindows_v5.1.4-35.exe
         설치된경로를 따라 Eclipse의 Profiler말고 Interpreter로 lua.exe로 path를 설정해주면 Eclipse에서 Project를 만든뒤 출력되는 Lua파일을 볼수 있다.
         근데 이상한데 UNICODE에서 계산해서 빼오더구만.
         추가 : 알고보니 UNICODE를 포함하는 방식중 하나라고한다. 근데 더 모르겠는데... U-00000800 - U-0000FFFF 범위에 들어간다고 하는데??
         http://blog.naver.com/declspec?Redirect=Log&logNo=10092640244
         http://divestudy.tistory.com/8
         package utfencoding;
         import java.io.UnsupportedEncodingException;
         import java.net.URLEncoder;
         public class UtfEncoding {
          final static char[] first = {
          final static char[] middle = {
          final static char[] last = {
          public static void main(String[] args) {
          String temp = "바";
  • [Lovely]boy^_^/ExtremeAlgorithmStudy/SortingAndOrderStatistics
         = Sorting Algorithms =
         === Foundation of Heapsort ===
          * 사용하는 자료구조 : Heap - 자료구조 시간엔 Complete Binary Tree로 구현방법을 배웠었다.
          * heap이 무엇인가 하면? A[Parent[i)] >= A[i] (결국 부모는 무조건 자식보다 커야한단 말입니다.)
          * Parent(i) : floors( (i-1) / 2 ) (책에는 맨 처음 index가 1이지만.. 우린 0에 익숙하므로..)
          * Left(i) : 2i + 1
          * Right(i) : 2i + 2 - 뭐 이것들은 Binary Tree의 기초니..--;
          * height : 세타(lgn)
         === Maintaining the heap property ===
         === Building a Heap ===
         === The heapsort algorithm ===
         === Priority Queue ===
          * QuickSort에 자주 까이면서도(책에는 beat라는 표현을..) 존재하는 이유 중의 하나가 우선순위큐를 구현할때라는데..--a라고 써있네요..--;
          * Insert
          * Maximum
          * Extract_Maximum
         == Quicksort ==
          * 여기서 잠깐, Comparison Sort(이건 또 뭐지?--;)는 아무리 빠르게 해봤자 세타(nlgn)보다는 빠르게 못한답니다.
         === Description ===
          * Divide and Conquer paradigm 을 쓴답니다.(보나마나 재귀군..--;)
  • 김재현
         == Intro ==
         msn--- syniori 골뱅이 hotmail.com
         싸이질--- syniori
         네이버블로그--- www.naver.com/syniori.do
         #include <stdio.h>
         #include <stdlib.h>
         #include <time.h>
         #define COUNT 6 // 당첨번호개수
         #define MAX 45 // 1-45
         #define TITLE "[ LOTTO RANDOM NUMBER GENERATOR ]\n"
         int main()
          unsigned char j,k,n, used[MAX];
          int i;
          printf(TITLE);
          printf("=================================\n");
          printf("Enter the game count: ");
          printf("=================================\n");
          srand(time(NULL));
          for (i=0; i < j; i++) {
          printf("game %2d: ", i+1);
  • 데블스캠프2006/월요일/연습문제/switch/윤영준
         #include <iostream.h>
         void main(void)
          int student[10], i=0, a=0, b=0, c=0, d=0, f=0;
          cin >> student[i];
          switch(student[i]/10){
          if(student[i]!=999)
          i++;
          }while((student[i-1] != 999) && (i<10));
  • 랜웍/이진훈
         #include <iostream>
         #include <ctime>
         using namespace std;
         const int Arsize = 3;
         int pan[3][3] = {
         int count = 1;
         int countz();
         void main()
          srand(time(0));
          int x = rand()%3;
          int y = rand()%3;
          int a = 0 , b = 0;
          int z = countz();
          while(z)
          if (a == 0 && b == 0)
          continue;
          else if ((x+a >= 0 && x+a < 3) && (y+b >= 0 && y+b < 3))
          }while(true);
          for (int i = 0;i<3;i++)//출력부..
          for (int k = 0;k<3;k++)
  • 문자반대출력/허아영
         *(pCh+lenstr-i-1) = temp[i]; 이 부분에서 자꾸
         *(pCh+lenstr-i) = temp[i]; 이렇게 코딩해서, 컴파일은 되는데, 결과물이 안나와서 답답했었다.
          choiceNum을 영어, 한글, 문자로 세분화 하려고 했으니 일단은 저렇게 코딩.
         #include <stdio.h>
         #include <string.h>
         #include <stdlib.h>
         char strchange(char ch[50], int lenstr);
         void main()
          int lenstr;
          FILE *fp1, *fp2;
          printf("Before string = %s \n", ch);
          printf("After string = %s \n", ch);
         char strchange(char *pCh, int lenstr)
          int i;
          for(i = 0; i <= lenstr; i++)
          temp[i] = *(pCh+i);
          for(i = 0; i <=lenstr; i++)
          *(pCh+lenstr-i-1) = temp[i];
         #include <stdio.h>
         #include <string.h>
  • 새싹C스터디2005/pointer
         int a = 1;
         int b = 2;
         int* c;
         int* d;
         #include <stdio.h>
         void Swap(int* aX, int* aY);
         int main()
          int x = 1;
          int y = 2;
          printf("x = %d\ny = %d\n이 변수의 값을 교환합니다.\n", x, y);
          printf("x = %d\ny = %d\n", x, y);
         void Swap(int* aX, int* aY){
          int temp;
         #include <stdio.h>
         void Swap(int aX, int aY);
         int main()
          int x = 1;
          int y = 2;
          printf("x = %d\ny = %d\n이 변수의 값을 교환합니다.\n", x, y);
          printf("x = %d\ny = %d\n", x, y);
  • 새싹교실/2012/AClass/1회차
         1. 컴파일(Compile), 빌드(Build), 링크(Linking)에 대해 책에서 찾아보고 써 주세요.
         -상수형 :상수는 변환 할 수 없는 고유의 수, 프로그램을 개발할 때 변경되어 발생 할 수 있는 버그등의 위험을 줄이기 위해 사용(#define,const)
          변수형 (변수의 데이터 타입을 선언해 준다.int, float)
         3.char형에 관해 써 주세요. ASCII코드를 통해 나타낸다는 것이 무엇을 의미하는지도 써 주세요.
          ascii코드는 표준으로 선택해서 문자를 표현함. 알파벳과 일부 특수문자를 포함하여 128개의 문자로 이루어짐
         4.#include, 전처리과정이 무엇인지 쓰고, include의 예를 들어주세요.
         -전처리 과정이랑 컴퓨터가 코딩한 파일을 컴파일 하기 전에 여러 텍스트를 바꾸고 고치는 기능. include<stdio.h>
         5.#define이 무엇을 의미하는지 쓰고, 이것을 사용한 '간단한' 프로그램을 하나 작성해보세요.
         - 확장성이 큰 것으로 , 긴 프로그램을 설계할 때 #define으로 정의된 것을 사용할수 있어서 편리하다.
         7.if, else, else if문을 이용한 프로그램을 하나 작성해주세요. else나 else if를 3번이상 써 주세요.
          ⁃ #include<stdio.h>
          int main(void)
          int num1;
          int num2;
          printf(“relationships they satisfy: ”);
          if(num1==num2){
          printf(“%d is equal to %d\n”, num1,num2);
          }else if(num1 != num2){
          printf(“%d is not equal to %d\n”, num1, num2);
          }else if(num1 < num2){
  • 새싹교실/2012/AClass/2회차
         #include<stdio.h>
         int main()
          int num =0;
          int sum =0;
          printf("0과 1000사이의 정수를 입력 :\n");
          }while(!(num == 0));
          printf("각 자리수들의 합 : %d \n",sum);
         #include <stdio.h>
         int main()
          printf("소문자 : ");
          if( 97 <= replace && replace <= 129){
          printf("대문자는 :%c\n", replace-32);
          }else if( 65 <=replace && replace <= 90){
          printf("대문자는 :%c\n", replace+32);
         방법은 if(10>x) printf(" ");입니다.
         #include<stdio.h>
         int main()
          int i,j;
          int num=1;
          for(i=0;i<5;i++){
  • 새싹교실/2012/AClass/3회차
         1~5.www.koistudy.net 코이스터디 100번~104번까지 Accept받기(등업이 안되어 있으면 그 문제의 소스를 저한테 보내주세요)
         -#include<stdio.h>
         int main()
          int a,b;
          printf("%d",a+b);
         -#include<stdio.h>
         int main()
         int a,b;
         printf("%d %d",a/b,a%b);
         -#include<stdio.h>
         int main()
         printf("%g ",a*b/2);
         -#include<stdio.h>
         int main()
         printf("%.2f ",c*c*3.14);
         -#include<stdio.h>
         int main()
         printf("%.3f ",(float)(n1+n2+n3)/3);
         -#include<stdio.h>
         void swap(int *a,int *b);
  • 새싹교실/2012/AClass/4회차
          11.이번시간에 배웠던 내용을 바탕으로, int* a; int b; int **c;로 선언했을때 &c,c,*c,&a,a에 관해서 각각 설명하고, 어떤 것이 어떤 것과 일치하는 것인지를 이해할 수 있도록 쉬운말로 정리해보세요.
          int* a;
         int b=5;
         int** c;
          printf("%d %d",*c,**c);
         -해설 : 우선 int형 자료형을 가진 데이터의 주소를 가리키는 포인터로 a지정, b의 값에 5를 지정, 포인터의 주소를 가리키는 c를 지정하였다. a의 주소를 이중 포인터 c에 주었다. b의 주소는 포인터 a에 할당하였다. 그리고 이중포인터c에 값을 9로 주었다. 이것은 원래의 a의 주소값을 갖고 있던 c에 9를 대체해준 것이다. 따라서 프린트 *c,**c를 하면 a의 주소와 9가 출력이 된다.
         2.Circular Queue가 무엇인지 찾아보자.
         - c언어에서는 char,int,float 와 같은 많은 수의 기본 데이터 형과 배열, 포인터, 구조체 등의 유도된 데이터형으로부터 새로운 데이터형을 만들 수 있는데, 사용자 측면에서 새로운 데이터 형을 정의 할 수 있도록 typedef선언을 제공한다. typedef은 #define과 달리 이미 존재하는 c언어의 데이터 형만을 취하여 정의하고 typedef은 프리프로세서에 의해 처리되는 것이 아니라 c컴파일러에 의해 처리된다. 또한 #define보다 다양한 형태의 치환이 가능하다.
         #include <stdio.h>
         void main()
          printf("name=%s \n",name);
          printf("color=%s \n",color);
          구조체 내부에 char 배열을 사용해서 이름을 넣어도 좋고, 학번을 int형으로 넣어도 좋다.
         #include<stdio.h>
         int age;
         int main()
         int i;
         struct Student stu[4]={24,"길±æ문¹�"},{24,"상≫o희En"},{23,"송¼U이AI"},{22,"혜Cy림¸²"};
         for(i=0;i<4;i++){
         printf("age : %d\n name : %s \n",stu[i].age,stu[i].name);
  • 새싹교실/2013/록구록구/8회차
         1. 5칸짜리 int형 배열을 선언합니다. 값은 임의로 정합니다.
         2. 5칸짜리 int형 배열을 선언합니다. 값은 scanf와 반복문을 사용하여 입력받습니다.
          int형 이기 때문에 소수점 이하가 잘리는 문제는 그냥 무시합니다. (출력 예시 참고!)
         #include <stdio.h>
         int main()
          int a[]={3,4,12,9,1};
          printf("%d\n", a[0]);
          printf("%d\n", a[1]);
          printf("%d\n", a[2]);
          printf("%d\n", a[3]);
          printf("%d\n", a[4]);
         #include <stdio.h>
         int main()
          int a[5]={0};
          int i;
          int sum=0,average=0;
          for(i=0;i<5;i++)
          scanf("%d",&a[i]);
          sum=sum+a[i];
          printf("합=%d\n",sum);
  • 새싹교실/2014/배반/6주차
         *주소값 출력은 그냥 printf 뒤에 &만
         #include <stdio.h>
         void show();
         int i,j;
         int num=1,k,move=-1, temp, l,m;
         int size;
         int array[11][11]={0,};
         int main()
          while(1)
          printf("사이즈를 입력하세요 : ");
          scanf("%d",&size);
          if(size>2 && size<12)
          printf("3에서 11사이만\n");
          num=size*size;
          temp=size;
          i=1;
          j=size+1;
          while(1)
          for(k=0;k<size;k++)
          array[i][j]=num;
  • 새싹교실/2015/의사양반/0501
         '''10강. 저 그냥 나갈게요''' ''+ Dynamic Memory Allocation''
          * '''후기 작성 요령''' : 후기는 F4(ThreeFs + Future Action Plan)에 맞게 작성해주세요.
          * Facts, Feelings, Findings, Future Action Plan. 즉, 사실, 느낀 점, 깨달은 점, 앞으로의 계획.
         a[i] 와 *(a+i) 는 같다.
         2차원 배열의 연산 : arr [m][n] + 1 과 arr [m][n+1]은 같다. (arr [m][n] + 1 하면 sizeof(data_type) 만큼 넘어간다)
         void* malloc (num) : num만큼의 크기의 메모리를 할당하는 것.(void포인터면 나중에 다른 타입의 포인터로 바꿔야 한다)
         #include<stdio.h>
         #pragma warning (disable : 4996)
         int main(void)
          int direction;//방향 : 오른쪽으로 한칸 가려면 1, 왼쪽으로 한칸 가려면 -1
          int i = 0; // 현위치
          int house[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };// 집: 차례대로 10채
          int arr[10]; // 줄 선물 할당 수
          int present = 100; // 선물 수: 100개
          int paper[10] = { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 };//원래 줘야할 선물 수
          int num = 0;
          printf("현재 위치는 %d번째 집입니다. \n", i + 1);
          printf("오른쪽에 있는 다음 칸으로 이동하려면 1을, 왼쪽에 있는 다음 칸 이동하려면 -1을, 계속 여기 있으려면 0을 눌러 enter키를 눌러주세요. \n(만약 틀려서 수정할 곳이 1번 째 집이 아니면 +1을 눌러주세요) \n");
          scanf("%d", &direction); //어디로 갈지 방향 지정
          if (i == 0 && direction == -1) // 0이나 9에서 넘어갈 경우에 대한 대비
  • 새싹교실/2016/고등어자반/0512
         #include <stdio.h>
         int getNumber(int num[]);
         int evenNumber(int num[],int count);
         int primeNumber(int num[],int count);
         int main()
          int n,num[99] = { 0 };
          int i,count;
          while (1)
          printf("1. 숫자 추가하기\n");
          printf("2. 짝수 제거하기\n");
          printf("3. 소수 제거하기\n");
          printf("어느 명령을 수행할까요? ");
          switch (n)
          primeNumber(num,count);
         int getNumber(int num[])
          int i, j, temp,count;
          printf("숫자를 입력하세요 가장 마지막에는 0을 입력하세요.\n");
          for (i = 0; i < 99; i++)
          scanf("%d", num[i]);
          if (num[i] = 0)
  • 새싹교실/2017
         [http://zeropage.org/index.php?mid=fresh&category=102321&document_srl=103605 강사메뉴얼]
         || 9 || [i] || 이민규 || 주광우, 최기수, 한재현 || 전과생 ||
         || 16 || [/studio.h] || 조현성 || 문법식, 박상현, 조성민 || ||
          * [http://www.compileonline.com/compile_c_online.php 온라인 컴파일러]
          * [http://www.cplusplus.com/reference/clibrary/ C 함수 라이브러리]
          * [HowTo/StudyProgrammingLanguage]
          * [HelpOnEditing]: 위키 편집 안내서
          * [HelpOnFormatting]
          * [HelpOnHeadlines]
          * [HelpOnLists]
  • 새싹교실/2017/내무반/박채린/17.05.18
          * 퀴즈으 sizeof(arr)/sizeof(int)
          * int *p= &i; //i의 주소를 알아냄
          * arr[i]==*(arr+i)
  • 새싹교실/2017/내무반/한윤진/17.05.18
          * arr[i]==*(arr+i)
  • 새싹교실/2021/C발라먹기/임지민
         #include <stdio.h>
         int fac(int n){
          int result=1;
          int i;
          if (n == 0){
          for (i = n; i >= 1; i--)
          result *= i;
         int main(void) {
          int n;
          printf("%d", fac(n));
         #include <stdio.h>
         int pibo(int n){
          int arr[21];
          int i;
          if(n ==0){
          else if(n == 1){
          for(i=2;i<=n;i++){
          arr[i] = arr[i-1] + arr[i-2];
         int main(void) {
          int n;
  • 새싹교실/2022/Java보시던지/05.05
          * import는 사용관계
         class Main {
          public static void main(String[] args) {
          final int DEFAULT_MAX = 10000;
          for(int i = 1; i < selfNumberArr.length; i++) {
          selfNumberArr[i] = true;
          for(int i = 1; i < selfNumberArr.length; i++) {
          if(d(i)<DEFAULT_MAX+1)
          selfNumberArr[d(i)] = false;
          for(int i = 1; i < selfNumberArr.length; i++) {
          if(selfNumberArr[i] == true)
          System.out.println(i);
          static int d (int n) {
          String nString = Integer.toString(n);
          String[] splitnStrings = nString.split("");
          int sum = n;
          for(int i = 0; i < splitnStrings.length; i++) {
          sum += Integer.parseInt(splitnStrings[i]);
         public class Main {
          public static void main(String[] args) {
  • 새싹교실/2022/Java보시던지/05.19
         Describe 새싹교실/2022/Java보시던지/05.19 here
         이미 알던내용들 - 접근제한자, static
          * if 부모 클래스와 자식 클래스에 같은 필드가 있을 때, 생성자의 this 키워드는 가장 가까운 자식 클래스를 참조한다. (부모 클래스 참조 X)
          * this 키워드로 부모 클래스를 참조할 때, 부모 클래스에 필드가 private로 접근 제한되어 있으면 참조 불가 (protected를 써야함)
          * ParenCt 클래스를 부모로 하는 자식 클래스 Child를 작성하세요.
         class Child extends Parent {
          /* <Child 클래스 조건>
          1. Child의 age, name, schoolName, friendNum을 초기화하는 생성자를 만드세요.
          2. Child의 필드는 String schoolName, int friendNum이 있습니다.
          3. minusFriends 메소드 : 메소드를 호출할 때마다 friendNum이 1씩 줄어듭니다.
          4. showChildInfo 메소드 : 메소드를 호출하면 Child의 나이, 이름, 학교이름, 친구 숫자를 출력합니다.
          String schoolName = "";
          int friendNum = 0;
          Child(){
          System.out.println("Child Default Constructor");
          Child (int _age, String _name, String _schoolName, int _friendNum) {
          friendNum = _friendNum;
          System.out.println("Child Constructor");
          void minusFriends() {
          if(friendNum > 0){
  • 오바마 협박글
         Do you know about Obama threats in South Korea?
         You never know what has happened in South Korea.
         A South Korean youth was arrested on suspicion of intimidating President Obama and threatening to kill Ambassador Lippert in 2015.
         Police and prosecutors have ignored his innocence claims since the beginning of the investigation and condemned him as a sexual pervert.
         For the politically inspired news leaks, police and prosecutors made him open to public criticism.
         South Korean journalists reproached him by revealing a distinctive hysteria of hatred and repulsion to disregard human rights of this man.
         During the trial toward guilty, attorneys and judges make up for the police and prosecutor's groundless and inconsistent investigation reports with modifications and complements.
         After about a year and two months of trial, the South Korean court sentenced him to 18 months in jail for allegedly attempting to threaten the US president because of fermenting the diplomatic troubles.
         He continued to make innocent claims, so he suffered hunger in solitary confinement during his imprisonment, harassed by jailers, and received unusual medicinal treatments in a psychiatric hospital.
         The corrupt doctors in a back-scratching alliance with jail injected unknown drugs to produce confession from him.
         South Koreans who numbed humanity forced him to commit suicide in order to close the case. For the first time in his life, he was greatly disappointed by the human nature.
         The prosecutor appealed against the decision because. 형량이 너무 가볍다. 그리고 검사는 징역 4년 6개월을 요구하다.
         About two and a half years later, the second trial is ongoing. The court has failed to make a ruling on the appeal, and has still extended his ban on leaving the country.
         The fabricated evidence at the first trial is found to have been concocted by his devoted mother, it is necessary to the judicial officers to start afresh to revise and to supplement to maintain to convict of the charge.
         The South Korean government will soon be choose the method of sentencing guilty, soothe the US government's anger, and conceal the torture and medication.
         I hope you may help him to receive a fair trial.
         If you keep the interest on this case, reveal the truth and remember him, he can get a fair trial in South Korea.
         I think there is no other way to help him better than this.
         If this is happening to our world as our indifference continues to build up, you maybe end up with facing the similar thing because the next will be you.
         Attach the news article that reported the case and the detailed document according to one likes.
  • 이상진
         Describe 알고있니/이상진 here
         * DP (memoization, tabulation)
         memoization은 top-down 방식으로 풀이하는 방식임. 민욱님은 이걸 연마했다고 함..
         민욱 지인분은 memoization, 점화식 두개의 이름으로 나누어서 부른다고 한다.
         e.g., ACM-ICPC에서 7시간 중 4시간 생각하고 1시간 코드짜는 극단적인 케이스도 있음 (민욱 지인)
         17줄 전역변수로 빼면 static안써도 됨
         #34 iterator문을 for in문으로 쓸 수 있다.
         LIS (Longest Increasing Subsequence) 를 손으로 계산해서 그린 테이블 주어짐.
         - dp[i] = max( dp[i-1], max(dp[j]+1, 단 data[j]<data[i] and j<i) )
         - 보통 DP는 min, max, sum을 사용한다.
         ## subsequence와 substring의 차이?
         테마:: 그래프나 트리가 아니라, 구현력을 위한 테마 (벡터를 노드, 엣지로 해결하기.) 참조 https://sunrinnote.tistory.com/101
         "가능하면 쉬운 애 부터 푼다 -> priority_queue 를 사용하자."
         priority queue에 음수를 넣으면 작은 것 부터 나온다. (야매꼼수)
         #** SPANNING TREE (신장트리)**
         ## 그래프를 트리로 만들었을 때, 이를 spanning tree라고 한다.
         https://bowbowbow.tistory.com/1
         BFS SPANNING TREE
         https://torbjorn.tistory.com/290
  • 자료구족발보쌈/0522
         #include<stdio.h>
         int sum_array (int*arr,int a)
          int sum = 0;
          for (int i = 0; i < a; i++)
          sum += arr[i];
         int main()
          int a = 10;
          int arr[10] = {1,1,1,1,1,1,1,1,1,1};
          printf("%d", sum_array(arr, a));
         #include<stdio.h>
         void func(char* arr[])
          int num = 0;
          while (num < 5)
          printf("%c\n", *arr[num]);
         int main()
         #include<stdio.h>
         int show(int * p, int n){
          int sum=0,i;
          for (i = 0; i < n; i++){
          sum += p[i];
Found 41 matching pages out of 7540 total pages

You can also click here to search title.

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
Processing time 0.0643 sec