잡다한 정보방

블로그 이미지
by 행복회로 풀가동

TAG CLOUD

  • Total hit
  • Today hit
  • Yesterday hit

'프로그래밍 언어'에 해당되는 글 4건

  1. 2018.05.24
    자바프로그래밍 (입력받은)10진수를 2진수로 변환-동적배열
  2. 2018.05.24
    자바프로그래밍 (입력받은)10진수를 2진수로 변환-정적배열
  3. 2018.05.24
    자바 프로그래밍 10진수를 2진수로 변환-정적배열
  4. 2018.05.19
    C언어 Stack클래스의 구조

키보드로 입력받고 동적배열:10진수 동적을 참고
//변수값을 가지며(Scanner) 동적배열(ArrayList),for문의 경우 동적배열의 크기 이용

package javaproj; //키보드로 정수값을 입력받기,동적배열 


import java.util.*;


public class HelloJava3 {

 

 public static void main(String[] args) {


  // TODO Auto-generated method stub

 

  ArrayList<Integer> binArray=new ArrayList<Integer>();


  System.out.print("10진수를 입력하시오:");

 

  Scanner sc=new Scanner(System.in);


  int num=sc.nextInt();


  int i=0;

 

  while(num!=0)


  {


  binArray.add(num%2);


  num=num/2;


  i++;


  }

 

  for(int j=binArray.size()-1;j>=0;j--)


  {


  System.out.print(binArray.get(j)+"");


  }

 

 }

 

}

 

AND

키보드로 입력받고 정적배열,length를 사용할 것. 예:for(int k=rest.length-1;~):


//변수값을 가지며(Scanner) 정적배열,for문의 경우 length를 사용

 

package javaproj;  //키보드로 정수값을 입력받기,정적배열(단,length를 사용할 것)  

 

import java.util.*;

 

public class HelloJava2 {

 

 public static void main(String[] args) {


  // TODO Auto-generated method stub

 

  System.out.println("10진수를 입력하시오");

 

  Scanner sc=new Scanner(System.in);


  int array[] =new int[10];


  int num=sc.nextInt();


  int i=0;

 

  while(num!=0)


  {


  array[i]=num%2;


  num=num/2;


  i++;


  }

 

  for(int j=array.length-1;j>=0;j--)


  {


  System.out.println(array[j]);


  }

 

 }

 

}

 

AND

package javaproj; //상수값을 2진수로 만들기,정적배열  

public class HelloJava2 {

 

 public static void main(String[] args) {


  // TODO Auto-generated method stub


  int Value=100;


  int i=0;


  int [] rest=new int [20];

 

  while(Value!=0)


  {


  rest[i]=Value%2;


  Value=Value/2;


  i++;


  }
  
       
  for(int j=19;j>=0;j--)


  {


  System.out.println(rest[j]);


  }

 


 }

 

}


 

AND

.스택 클래스의 UML클래스 다이어그램

 

#include <iostream>

using namespace std;

 

class Stack

{

protected:

int m_size;

int m_top;

int m_buffer;

 

public:

void Initialize(int size=10);

void Remove All();

bool Push(int value);

bool Pop(int& value);

};

 

void Stack::Initialize(int size)

{

m_size=size;

m_top=-1;

m_buffer=new int[m_size];

memset=(m_buffer,0,sizeof(int)*m_size);

}

 

void Stack::Remove All()

{

m_size=0;

m_top=-1;

delete [] m_buffer;

m_buffer=NULL;

}

 

 

 

 

 

 

 

bool Stack::Push(int value)

{

if(m_top>=m_size-1) return false;

m_buffer[++m_top]=value;

return true;

}

 

bool Stack::Pop(int& value)

{

if(m_top<0) return false;

value=m_buffer[m_top--];

return true;

}

 

int main()

{

stack s1;

s1.Initialize(5);

while(s1.Push(rand()%100));

cout<<“s1에 저장된 데이터 : ”;

for(int 1=0;i<s1.m_size;i++)

cout<<s1.m_buffer[i]<<“ ”;

cout<<“\n”;

cout<<“s1에서 꺼낸 데이터 : ”;

int data;

while(s1.Pop(data))

cout<<data<<“ ”;

cout<<“\n”;

 

system(“pause”);

return 0;

}

 

 

 

AND

ARTICLE CATEGORY

분류 전체보기 (27)
전력전기전자 (1)
건강정보 (4)
잡다한 지식 (2)
자동차 (5)
IT (3)
리눅스 (1)
네트워크 (3)
프로그래밍 언어 (4)
웹 지식(ver22년도) (3)

RECENT ARTICLE

RECENT COMMENT

CALENDAR

«   2025/05   »
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 29 30 31

ARCHIVE