게시판 게시물

wimpy15
2021년 1월 21일
In 소스 코드 제출
import java.awt.*; import javax.swing.*; import java.awt.event.*; class GamblingThread extends Thread { JLabel la = new JLabel(); boolean gambling = false; synchronized public void waitforGambling() { if(!gambling) { try { this.wait(); } catch(InterruptedException e) { return; } } } synchronized public void startGambling() { gambling = true; this.notify(); } public void run() { while(true) { waitforGambling(); try { Thread.sleep(200); if(gambling == true) { la.setText("성공"); } else { la.setText("실패"); } } catch (InterruptedException e) { // TODO: handle exception return; } gambling = false; } } } class MyMouseListener extends MouseAdapter { public void mouseClicked(MouseEvent e) { JLabel la = (JLabel)e.getSource(); GamblingThread g = new GamblingThread(); Thread th = new Thread(g); th.start(); } } public class Main extends JFrame { public Main() { setTitle("스레드가 가진 겜블링"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout()); setSize(1000,1000); setVisible(true); } public static void main(String[] args) { new Main(); } }
0
0
3
wimpy15
2021년 1월 14일
In 소스 코드 제출
//import java.awt.*; //import javax.swing.*; //import java.awt.event.*; // //class TimerRunnable implements Runnable //{ // private JLabel timerLabel; // // public TimerRunnable(JLabel timerLabel) // { // this.timerLabel = timerLabel; // } // // @Override // public void run() { // // TODO Auto-generated method stub // int n = 0; // while(true) // { // timerLabel.setText(Integer.toString(n)); // n++; // try { // Thread.sleep(1000); // } // catch (InterruptedException e) { // // TODO: handle exception // return; // } // } // } //} //public class Main extends JFrame //{ // private Thread th; // public Main() // { // setTitle("ThreadInterruptex"); // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Container c = getContentPane(); // c.setLayout(new FlowLayout()); // // JLabel timerLabel = new JLabel(); // timerLabel.setFont(new Font("Gothic",Font.ITALIC,80)); // // TimerRunnable runnable = new TimerRunnable(timerLabel); // th = new Thread(runnable); // c.add(timerLabel); // // JButton btn = new JButton("kill Timer"); // btn.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent e) { // // TODO Auto-generated method stub // th.interrupt(); // JButton btn = (JButton)e.getSource(); // btn.setEnabled(false); // } // }); // c.add(btn); // // setSize(300,170); // setVisible(true); // // th.start(); // } // public static void main(String[] args) { // new Main(); // } //} //import java.awt.*; //import javax.swing.*; // //class SharedBoard //{ // private int sum = 0; // synchronized public void add() // { // int n = sum; // Thread.yield(); // n += 10; // sum = n; // System.out.println(Thread.currentThread().getName() + ":" + sum); // } // public int getSum() // { // return sum; // } //} // //class StudentThread extends Thread //{ // private SharedBoard board; // // public StudentThread(String name, SharedBoard board) // { // super(name); // this.board = board; // } // public void run() // { // for(int i = 0; i < 10; i++) // { // board.add(); // } // } //} // //public class Main //{ // public static void main(String[] args) { // SharedBoard board = new SharedBoard(); // // Thread th1 = new StudentThread("kitae", board); // Thread th2 = new StudentThread("hyosoo", board); // // th1.start(); // th2.start(); // } //} //import javax.swing.*; //import java.awt.*; //import java.awt.event.*; // //class MyLabel extends JLabel //{ // private int barSize = 0; // private int maxBarSize; // // public MyLabel(int maxBarSize) // { // this.maxBarSize = maxBarSize; // } // // public void paintComponent(Graphics g) // { // super.paintComponent(g); // g.setColor(Color.magenta); // int width = (int)(((double)(this.getWidth()))/maxBarSize*barSize); // if(width == 0) return; // g.fillRect(0, 0, width, this.getHeight()); // } // synchronized public void fill() // { // if(barSize == maxBarSize) // { // try // { // wait(); // } // catch(InterruptedException e) // { // return; // } // barSize++; // repaint(); // notify(); // } // } // synchronized public void consume() // { // if(barSize == 0) // { // try // { // wait(); // } // catch(InterruptedException e) // { // return; // } // barSize--; // repaint(); // notify(); // } // } //} //class ConsumerThread extends Thread //{ // private MyLabel bar; // public ConsumerThread(MyLabel bar) // { // this.bar = bar; // } // public void run() // { // while(true) // { // try // { // sleep(200); // bar.consume(); // } // catch (InterruptedException e) { // // TODO: handle exception // return; // } // } // } //} // //public class Main extends JFrame //{ // private MyLabel bar = new MyLabel(100); // // public Main(String title) // { // super(title); // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Container c= getContentPane(); // c.setLayout(null); // bar.setBackground(Color.orange); // bar.setOpaque(true); // bar.setLocation(20,50); // bar.setSize(300, 20); // c.add(bar); // // c.addKeyListener(new KeyAdapter() { // public void keyPressed(KeyEvent e) // { // bar.fill(); // } // }); // setSize(350,200); // setVisible(true); // // c.setFocusable(true); // c.requestFocus(); // ConsumerThread th = new ConsumerThread(bar); // th.start(); // } // public static void main(String[] args) { // new Main("아무키나 빨리 눌러 바 채우기"); // } //}
0
0
1
wimpy15
2021년 1월 06일
In 소스 코드 제출
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Main extends JFrame { Container c = getContentPane(); JLabel la = new JLabel(); JLabel la1 = new JLabel("me"); JLabel la2 = new JLabel("com"); JButton b1 = new JButton(new ImageIcon("C:\\Users\\user\\Desktop\\images\\scissors.jpg")); JButton b2 = new JButton(new ImageIcon("C:\\Users\\user\\Desktop\\images\\rock.jpg")); JButton b3 = new JButton(new ImageIcon("C:\\Users\\user\\Desktop\\images\\paper.jpg")); JLabel bm = new JLabel(); JLabel bc = new JLabel(); public Main() { setTitle("Image Gallery Practice Frame"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MyActionListener ac = new MyActionListener(); c.setLayout(new FlowLayout()); b1.addActionListener(ac); b2.addActionListener(ac); b3.addActionListener(ac); c.add(b1); c.add(b2); c.add(b3); c.add(bm); c.add(la1); c.add(bc); c.add(la2); setSize(1000,1000); setVisible(true); } class MyActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { JButton bu = (JButton)e.getSource(); int ran = (int)(Math.random()*3); if(ran==0) { bc.setIcon(new ImageIcon("C:\\Users\\user\\Desktop\\images\\scissors.jpg")); } else if(ran==1) { bc.setIcon(new ImageIcon("C:\\Users\\user\\Desktop\\images\\rock.jpg")); } else { bc.setIcon(new ImageIcon("C:\\Users\\user\\Desktop\\images\\paper.jpg")); } if(bu==b1) { } //if(이겼을때) //{ // la.setText("win"); //} } } public static void main(String[] args) { new Main(); } }
0
0
2
wimpy15
2020년 11월 24일
In 소스 코드 제출
/* import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Main extends JFrame { public Main() { super("JComponent의 공통 메소드 예제"); Container c = getContentPane(); c.setLayout(new FlowLayout()); JButton b1 = new JButton("Magenta/Yellow Button"); JButton b2 = new JButton(" Disabled Button "); JButton b3 = new JButton("getX(), getY()"); b1.setBackground(Color.YELLOW); b1.setBackground(Color.magenta); b1.setFont(new Font("Arial",Font.ITALIC,20)); b2.setEnabled(false); b3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JButton b = (JButton)e.getSource(); Main frame = (Main)b.getTopLevelAncestor(); frame.setTitle(b.getX() + "," + b.getY()); } }); c.add(b1); c.add(b2); c.add(b3); setSize(260,200); setVisible(true); } public static void main(String[] args) { new Main(); } } */ /* import javax.swing.*; import java.awt.*; public class Main extends JFrame { public Main() { setTitle("이미지 버튼 예제"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout()); ImageIcon normalIcon = new ImageIcon("C:\\Users\\user\\Desktop\\보통상태.gif"); ImageIcon rolloverIcon = new ImageIcon("C:\\Users\\user\\Desktop\\버튼 위로.gif"); ImageIcon pressedIcon = new ImageIcon("C:\\Users\\user\\Desktop\\마우스 클릭.gif"); JButton btn = new JButton("call~~",normalIcon); btn.setPressedIcon(pressedIcon); btn.setRolloverIcon(rolloverIcon); c.add(btn); setSize(250,150); setVisible(true); } public static void main(String[] args) { new Main(); } } */ /* import javax.swing.*; import java.awt.*; public class Main extends JFrame { public Main() { setTitle("체크박스 만들기 예제"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout()); ImageIcon cherryIcon = new ImageIcon("C:\\Users\\user\\Desktop\\cherry.jpg"); ImageIcon selectedCherryIcon = new ImageIcon("C:\\Users\\user\\Desktop\\selectedCherry.jpg"); JCheckBox apple = new JCheckBox("사과"); JCheckBox pear = new JCheckBox("배",true); JCheckBox cherry = new JCheckBox("체리",cherryIcon); cherry.setBorderPainted(true); cherry.setSelectedIcon(selectedCherryIcon); c.add(apple); c.add(pear); c.add(cherry); setSize(250,150); setVisible(true); } public static void main(String[] args) { new Main(); } } */ //import javax.swing.*; //import java.awt.event.*; //import java.awt.*; // //public class Main extends JFrame //{ // private JCheckBox [] fruits = new JCheckBox[3]; // private String [] names = {"사과", "배", "체리"}; // // private JLabel sumLabel; // public Main() // { // setTitle("체크박스와 ItemEvent 예제"); // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Container c = getContentPane(); // c.setLayout(new FlowLayout()); // // c.add(new JLabel("사과 100원, 배 500원, 체리 20000원 ")); // // MyItemListener listener = new MyItemListener(); // for(int i = 0; i < fruits.length; i++) // { // fruits[i] = new JCheckBox(names[i]); // fruits[i].setBorderPainted(true); // c.add(fruits[i]); // fruits[i].addItemListener(listener); // } // // sumLabel = new JLabel("현재 0원 입니다."); // c.add(sumLabel); // setSize(250,300); // setVisible(true); // } // // class MyItemListener implements ItemListener // { // private int sum = 0; // // public void itemStateChanged(ItemEvent e) // { // // if(e.getStateChange()== ItemEvent.SELECTED) // { // if(e.getItem() == fruits[0]) // sum += 100; // else if(e.getItem() == fruits[1]) // { // sum += 500; // } // else // { // sum += 20000; // } // } // else // { // if(e.getItem() == fruits[0]) // { // sum -= 100; // } // else if(e.getItem() == fruits[1]) // { // sum -= 500; // } // else // { // sum -= 20000; // } // } // sumLabel.setText("현재 " + sum + "원 입니다."); // } // } // public static void main(String[] args) { // new Main(); // } // //} /* import javax.swing.*; import java.awt.*; public class Main extends JFrame { public Main() { setTitle("라디오버튼 만들기 예제"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout()); ImageIcon cherryIcon = new ImageIcon("C:\\Users\\user\\Desktop\\cherry.jpg"); ImageIcon selectedCherryIcon = new ImageIcon("C:\\Users\\user\\Desktop\\selectedCherry.jpg"); ButtonGroup g = new ButtonGroup(); JRadioButton apple = new JRadioButton("사과"); JRadioButton pear = new JRadioButton("배",true); JRadioButton cherry = new JRadioButton("체리",cherryIcon); cherry.setBorderPainted(true); cherry.setSelectedIcon(selectedCherryIcon); g.add(apple); g.add(pear); g.add(cherry); c.add(apple); c.add(pear); c.add(cherry); setSize(250,150); setVisible(true); } public static void main(String[] args) { new Main(); } } */ /* import javax.swing.*; import javax.swing.border.Border; import java.awt.event.*; import java.awt.*; public class Main extends JFrame { private JRadioButton [] radio = new JRadioButton [3]; private String [] text = {"사과", "배", "체리"}; private ImageIcon [] image = { new ImageIcon("C:\\Users\\user\\Desktop\\apple.jpg"), new ImageIcon("C:\\Users\\user\\Desktop\\pear.jpg"), new ImageIcon("C:\\Users\\user\\Desktop\\cherry.jpg") }; private JLabel imageLabel = new JLabel(); public Main() { setTitle("라디오 버튼 Item Event 예제"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new BorderLayout()); JPanel radioPanel = new JPanel(); radioPanel.setBackground(Color.GRAY); ButtonGroup g = new ButtonGroup(); for(int i = 0; i < radio.length; i++) { radio[i] = new JRadioButton(text[i]); g.add(radio[i]); radioPanel.add(radio[i]); radio[i].addItemListener(new MyItemListener()); } radio[2].setSelected(true); c.add(radioPanel,BorderLayout.NORTH); c.add(imageLabel,BorderLayout.CENTER); imageLabel.setHorizontalAlignment(SwingConstants.CENTER); setSize(250,200); setVisible(true); } class MyItemListener implements ItemListener { public void itemStateChanged(ItemEvent e) { if(e.getStateChange() == ItemEvent.DESELECTED) { return; } if(radio[0].isSelected()) { imageLabel.setIcon(image[0]); } else if(radio[1].isSelected()) { imageLabel.setIcon(image[1]); } else { imageLabel.setIcon(image[2]); } } } public static void main(String[] args) { new Main(); } } */ //import javax.swing.*; //import java.awt.*; // //public class Main extends JFrame //{ // public Main() // { // setTitle("텍스트 필드 만들기 예제"); // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // // Container c = getContentPane(); // c.setLayout(new FlowLayout()); // // c.add(new JLabel("이름 ")); // c.add(new JTextField(20)); // c.add(new JLabel("학과")); // c.add(new JTextField("컴공",20)); // c.add(new JLabel("주소 ")); // c.add(new JTextField("서울시 ...",20)); // // setSize(300,150); // setVisible(true); // } // public static void main(String[] args) { // new Main(); // } //} /* import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Main extends JFrame { private JTextField tf = new JTextField(20); private JTextArea ta = new JTextArea(7,20); public Main() { setTitle("텍스트영역 만들기 예제"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(new JLabel("입력 후 <Enter>키 입력하시오")); c.add(tf); c.add(new JScrollPane(ta)); tf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JTextField t = (JTextField)e.getSource(); ta.append(t.getText() + "\n"); t.setText(""); } }); } } */
0
0
1
wimpy15
2020년 11월 08일
In 소스 코드 제출
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; public class Main extends JFrame { private JLabel la = new JLabel("Love Java"); public Main() { setTitle("Left 키로 문자열 이동"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.addKeyListener(new MyKeyListener()); c.add(la); setSize(300,200); setVisible(true); c.setFocusable(true); c.requestFocus(); } class MyKeyListener extends KeyAdapter { int KeyCode = 0; String text = la.getText(); public void keyPressed(KeyEvent e) { KeyCode = e.getKeyCode(); if(KeyCode == KeyEvent.VK_LEFT) { char tmp = text.charAt(0); String tStr = text.substring(1); text = tStr + tmp; la.setText(text); } } } public static void main(String[] args) { new Main(); } }
0
1
6
wimpy15
2020년 10월 11일
In 소스 코드 제출
/* //문제 8 import javax.swing.*; import java.awt.*; import java.util.*; public class Main extends JFrame { public Main() { setTitle("여러 개의 패널을 가진 프레임"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new BorderLayout(30,20)); JPanel panal = new JPanel(); JButton b = new JButton("열기"); JButton bu = new JButton("닫기"); JButton but = new JButton("나가기"); panal.add(b); panal.add(bu); panal.add(but); panal.setBackground(Color.GRAY); c.add(panal, BorderLayout.NORTH); JPanel panal_1 = new JPanel(); Random rand = new Random(); for(int i = 0; i < 10; i++) { JLabel label = new JLabel("*"); int x = (int)(rand.nextInt(500)); int y = (int)(rand.nextInt(500)); System.out.println("x = "+x +" y = " +y); label.setLocation(x,y); label.setSize(10,10); label.setOpaque(true); c.add(label); } c.add(panal_1, BorderLayout.CENTER); JPanel panal_2 = new JPanel(); JButton button = new JButton("Word Input"); JTextField f = new JTextField(" "); panal_2.add(button); panal_2.add(f); panal_2.setBackground(Color.GREEN); c.add(panal_2, BorderLayout.SOUTH); setSize(600,600); setVisible(true); } public static void main(String[] args) { new Main(); } } */ /* //문제 7 import javax.swing.*; import java.awt.*; public class Main extends JFrame { public Main() { setTitle("계산기 프레임"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new BorderLayout(30,20)); JPanel panel = new JPanel(); JLabel label = new JLabel("수식입력"); JTextField f = new JTextField(" "); panel.add(label); panel.add(f); panel.setBackground(Color.GRAY); c.add(panel,BorderLayout.NORTH); JPanel panel_1 = new JPanel(); GridLayout grid = new GridLayout(4,4); grid.setVgap(5); panel_1.setLayout(grid); int [][] a =new int [10][10]; int cnt=0; for(int i = 0; i < 3; i++) { for(int j = 0; j < 4; j++) { JButton b = new JButton(Integer.toString(i*4+j)); panel_1.add(b); cnt++; if(cnt==10) break; } } panel_1.add(new JButton("CE")); panel_1.add(new JButton("계산")); JButton bu= new JButton("+"); bu.setBackground(Color.cyan); panel_1.add(bu); bu= new JButton("-"); bu.setBackground(Color.cyan); panel_1.add(bu); bu = new JButton("x"); bu.setBackground(Color.CYAN); panel_1.add(bu); bu = new JButton("/"); bu.setBackground(Color.CYAN); panel_1.add(bu); c.add(panel_1,BorderLayout.CENTER); JPanel panel_2 = new JPanel(); JLabel label_2 = new JLabel("계산결과"); JTextField f_2 = new JTextField(" "); panel_2.add(label_2); panel_2.add(f_2); panel_2.setBackground(Color.GREEN); c.add(panel_2,BorderLayout.SOUTH); setSize(600,600); setVisible(true); } public static void main(String[] args) { new Main(); } } */
0
0
3
wimpy15
2020년 9월 20일
In 소스 코드 제출
/* import java.util.*; interface Stack { int length(); int capacity(); String pop(); boolean push(String val); } class StringStack implements Stack { int x, top; String[] save; public StringStack(int x) { this.x = x; save = new String[x]; top = 0; } @Override public int length() { return top; } @Override public int capacity() { return x; } @Override public String pop() { return save[--top]; } @Override public boolean push(String val) { if(top == x) { return false; } else { save[top] = val; top++; return true; } } } public class Main { public static void main(String[] args) { int x; String st; Scanner s = new Scanner(System.in); System.out.println("총 스택 저장 공간의 크기 입력 >>"); x= s.nextInt(); StringStack stst = new StringStack(x); for(;;) { System.out.println("문자열 입력>>"); st = s.next(); if(st.equals("그만")) { break; } if(!stst.push(st)) { System.out.println("스택이 꽉차서 푸시 불가!"); } } System.out.println("스택에 저장된 모든 문자열 팝 : "); for(int i = 0;i < x; i++) { System.out.print(stst.pop()+" "); } } } */ /* import java.util.*; class Point { private int x,y; public Point(int x, int y) { this.x = x; this.y = y; } } public class Main { public static void print(Object obj) { System.out.println(obj.getClass().getName()); System.out.println(obj.hashCode()); System.out.println(obj.toString()); System.out.println(obj); } public static void main(String[] args) { Point p = new Point(2,3); print(p); } } */ /* import java.util.*; class Point { int x,y; public Point(int x, int y) { this.x = x; this.y = y; } public String toString() { return "Point(" + x + "," + y + ")"; } } public class Main { public static void main(String[] args) { Point p = new Point(2,3); System.out.println(p.toString()); System.out.println(p); System.out.println(p + "입니다."); } } */ /* import java.util.*; class Point { int x, y; public Point(int x, int y) { this.x = x; this.y = y; } public boolean equals(Object obj) { Point p = (Point)obj; if(x == p.x && y == p.y) { return true; } else return false; } } public class Main { public static void main(String[] args) { Point a = new Point(2,3); Point b = new Point(2,3); Point c = new Point(3,4); if(a==b) { System.out.println("a==b"); } if(a.equals(b)) { System.out.println("a is equal to b"); } if(a.equals(c)) { System.out.println("a is equal to c"); } } } */ /* import java.util.*; public class Main { public static void main(String[] args) { String a = new String("This is a pencil"); String b = new String("This is a pencil"); String c = a; if(a==b) { System.out.println("a==b"); } if(a==c) { System.out.println("a==c"); } if(a.equals(b)) { System.out.println("a is equal to b"); } } } */ import java.util.*; public class Main { public static void main(String[] args) { System.out.println(Character.toLowerCase('A')); char c1 = '4', c2 = 'F'; if(Character.isDigit(c1)) System.out.println(c1 + "는 숫자"); if(Character.isAlphabetic(c2)) System.out.println(c2 + "는 영문자"); System.out.println(Integer.parseInt("28")); System.out.println(Integer.toString(28)); System.out.println(Integer.toBinaryString(28)); System.out.println(Integer.bitCount(28)); Integer i = Integer.valueOf(28); System.out.println(i.doubleValue()); Double d = Double.valueOf(3.14); System.out.println(d.toString()); System.out.println(Double.parseDouble("3.14")); boolean b = (4>3); System.out.println(Boolean.toString(b)); System.out.println(Boolean.parseBoolean("false")); } }
0
0
3
wimpy15
2020년 9월 19일
In 소스 코드 제출
/* import java.util.*; interface Shape { final double PI = 3.14; void draw(); double getArea(); default public void redraw() { System.out.println("---다시 그립니다. "); draw(); } } class Circle implements Shape { int i; public Circle(int i) { this.i = i; } @Override public void draw() { // TODO Auto-generated method stub System.out.println("반지름이" + i +" 인 원입니다."); } @Override public double getArea() { // TODO Auto-generated method stub return PI * i*i; } } class Oval implements Shape { int a, b; public Oval(int a, int b) { // TODO Auto-generated constructor stub this.a = a; this.b = b; } @Override public void draw() { // TODO Auto-generated method stub System.out.println(a + "X" + b + "에 내접하는 타원입니다."); } @Override public double getArea() { // TODO Auto-generated method stub return PI*a*b; } } class Rect implements Shape { int i, j; public Rect(int i, int j) { this.i = i; this.j = j; // TODO Auto-generated constructor stub } @Override public void draw() { // TODO Auto-generated method stub System.out.println(i + "X" + j + "크기의 사각형 입니다."); } @Override public double getArea() { // TODO Auto-generated method stub return i*j; } } public class Main { public static void main(String[] args) { Shape [] list = new Shape[3]; list[0] = new Circle(10); list[1] = new Oval(20,30); list[2] = new Rect(10,40); for(int i = 0; i < list.length; i++) { list[i].redraw(); } for(int i = 0; i < list.length; i++) { System.out.println("면적은 " + list[i].getArea()); } } } */ import java.util.*; interface Stack { int length(); int capacity(); String pop(); boolean push(String val); } class StringStack implements Stack { int x,top; String[] save ; public StringStack(int x) { this.x = x; save = new String[x]; top = 0; } @Override public int length() { return top; } @Override public int capacity() { return x; } @Override public String pop() { return save[--top]; } @Override public boolean push(String val) { if(top == x) { return false; } else { save[top] = val; top++; return true; } } } public class Main { public static void main(String[] args) { int x; String st; Scanner s = new Scanner(System.in); System.out.println("총 스택 저장 공간의 크기 입력 >>"); x= s.nextInt(); StringStack stst = new StringStack(x); for(;;) { System.out.println("문자열 입력>>"); st = s.next(); if(st.equals("그만")) { break; } if(!stst.push(st)) { System.out.println("스택이 꽉차서 푸시 불가!"); } } System.out.println("스택에 저장된 모든 문자열 팝 : "); for(int i = 0;i < x; i++) { System.out.print(stst.pop()+" "); } } }
0
0
5
wimpy15
2020년 8월 06일
In 소스 코드 제출
//import java.util.*; // //class Point //{ // private int x, y; // public void set(int x, int y) // { // this.x = x; // this.y = y; // } // public void showPoint() // { // System.out.println("(" + x + "," + y + ")"); // } //} // //class ColorPoint extends Point //{ // private String color; // public void setColor(String color) // { // this.color = color; // } // // public void showColorPoint() // { // System.out.print(color); // showPoint(); // } //} //public class Main //{ // public static void main(String[] args) { // Point p = new Point(); // p.set(1, 2); // p.showPoint(); // // ColorPoint cp = new ColorPoint(); // cp.set(3, 4); // cp.setColor("red"); // cp.showColorPoint(); // } //} //import java.util.*; // //class A //{ // public A() // { // System.out.println("생성자A"); // } // // public A(int x) // { // System.out.println("매개변수생성자A" + x); // } //} //class B extends A //{ // public B() // { // super(30); // System.out.println("생성자 B"); // } // public B(int x) // { // System.out.println("매개변수생성자B" + x); // } //} //public class Main //{ // public static void main(String[] args) { // B b = new B(); // } //}
0
0
1
wimpy15
2020년 8월 05일
In 소스 코드 제출
//public class Main //{ // public static void main(String[] args) { // Circle pizza = new Circle(5); // Circle waffle = new Circle(1); // // boolean res = CircleManager.equals(pizza,waffle); // if(res == true) // { // System.out.println("pizza와 waffle 크기 같음"); // } // else // { // System.out.println("pizza와 waffle 크기 다름"); // } // // CircleManager.copy(pizza, waffle); // res = CircleManager.equals(pizza, waffle); // if(res == true) // { // System.out.println("pizza와 waffle 크기 같음"); // } // else // { // System.out.println("pizza와 waffle 크기 다름"); // } // // // } //} //import java.util.*; // //public class Main //{ // private int width, height; // private char fillChar; // public Main() // { // this(10,1); // } // public Main(int width, int height) // { // this.width = width; // this.height = height; // // } // public void draw() // { // for(int i = 0; i < height; i++) // { // for(int j = 0; j < width; j++) // { // System.out.print(fillChar); // } // System.out.print("\n"); // } // } // public void fill(char c) // { // fillChar = c; // } // public static void main(String[] args) { // Main a = new Main(); // Main b = new Main(20,3); // a.fill('*'); // b.fill('%'); // a.draw(); // b.draw(); // } //} //import java.util.*; // //class Player //{ // private String name; // Player(String name) // { // this.name = name; // } // public String getName() // { // return name; // } //} // //public class Main //{ // public static void main(String[] args) { // Scanner s = new Scanner(System.in); // Player [] p = new Player[2]; // for(int i = 0; i < 2; i++) // { // System.out.println("선수 이름 입력 >>"); // p[i] = new Player(s.next()); // } // int n = 0; // while(true) // { // System.out.print(p[n].getName() + " <Enter 외 아무키나 치세요>"); // s.next(); // int [] val = new int [3]; // for(int i = 0; i < val.length; i++) // { // val[i] = (int)(Math.random()*3); // System.out.print(val[i] + "\t"); // } // System.out.println(); // if(val[0] == val[1] && val[0] == val[2] && val[1] == val[2]) // { // System.out.println(p[n].getName()+"이 승리하였습니다"); // break; // } // n++; // n = n%2; // } // s.close(); // } //}
0
0
1
wimpy15
2020년 8월 04일
In 소스 코드 제출
import java.util.*; public class Main { String title; public Main(String title) { this.title = title; } public String getTitle() { return title; } public static void main(String[] args) { Main mySong = new Main("Nessun Dorma"); Main yourSong = new Main("공주는 잠 못 이루고"); System.out.println("내 노래는 "+ mySong.getTitle()); System.out.println("너 노래는 "+ yourSong.getTitle()); } } */ import java.util.Scanner; class Phone { String name, tell; public Phone(String na,String te) { name = na; tell = te; } public String getTell(String na) { if(name.equals(na)) { return tell; } else { return " "; } } } public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("인원수>>"); int n = s.nextInt(); Phone [] p = new Phone[n]; for(int i = 0; i < n ; i++) { System.out.println("이름과 전화번호>>"); String na = s.next(); String tel = s.next(); p[i]= new Phone(na, tel); } System.out.println("저장되었습니다..."); while(true) { System.out.println("검색할 이름>>"); String na1 = s.next(); if(na1.equals("exit")) { System.out.println("프로그램을 종료"); break; } for(int i = 0 ; i<n ; i++) { String result = p[i].getTell(na1); if(result != " ") { System.out.println(na1 + "의 번호는 "+result+" 입니다."); break; } if(i==n-1) { System.out.println(na1 + " 이 없습니다."); } } } } } /* import java.util.Scanner; public class Main { private String name, tel; public Main(String name, String tel) { this.name = name; this.tel = tel; } public String getname() { return name; } public String getTel() { return tel; } public static void main(String[] args) { Scanner s = new Scanner(System.in); Main [] m = new Main[2]; for(int i = 0; i < 2; i++) { System.out.println("이름과 전화번호 입력 >> "); String n = s.next(); String t = s.next(); m[i] = new Main(n,t); } for(int i = 0; i < 2; i++) { System.out.println(m[i].name+"의 번호" + m[i].tel); } } } */ //import java.util.Scanner; // //class Rect //{ // private int width, height; // public Rect(int width, int height) // { // this.height = height; // this.width = width; // } // public int getArea() // { // return width*height; // } //} // //public class Main //{ // public static void main(String[] args) // { // Scanner s = new Scanner(System.in); // Rect [] m = new Rect[4]; // int sum = 0; // for(int i = 0; i < 4; i++) // { // System.out.println("너비와 높이>>"); // int w = s.nextInt(); // int h = s.nextInt(); // m[i] = new Rect(w,h); // } // System.out.println("저장하였습니다."); // // for(int i = 0; i < 4; i++) // { // sum+=m[i].getArea(); // } // System.out.println("사각형의 전체 합은 " + sum); // // // } //}
0
0
1
wimpy15
2020년 8월 01일
In 소스 코드 제출
//import java.util.*; // //class Tv //{ // String s; // int y; // int size; // public Tv(String s,int y,int size) // { // this.s = s; // this.y = y; // this.size = size; // } // public void show() { // System.out.print(s + "에서 만든 " + y + "년형 " + size + "인치 TV"); // } //} // //public class Main { // public static void main(String[] args) { // Tv myTv = new Tv("LG",2017,32); // myTv.show(); // } // } /* import java.util.Scanner; class Grade { int math; int science; int english; public Grade(int math, int science, int english) { this.math = math; this.english = english; this.science = science; } public int average() { return (math + science + english)/3; } } public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.print("수학, 과학, 영어 순으로 3개의 점수 입력>>"); int math = s.nextInt(); int science = s.nextInt(); int english = s.nextInt(); Grade me = new Grade(math, science, english); System.out.println("평균은 "+ me.average()); } } */ //import java.util.*; // //class Song //{ // String title; // String artist; // int year; // String country; // public Song(int year, String country, String artist, String title) // { // this.artist = artist; // this.country = country; // this.title = title; // this.year = year; // } // public void show() // { // System.out.println(year + "년 " + country + "국적의 " + artist + "가 부른 " + title); // } //} // //public class Main //{ // public static void main(String[] args) { // Song s = new Song(1978, "스웨덴", "ABBA", "Dancing Queen"); // s.show(); // } //} import java.util.Scanner; class Circle { private double x, y; private double radius; public Circle(double x, double y, double radius2) { this.radius = radius2; this.x = x; this.y = y; } public void show() { System.out.println("(" + x + "," + y + ")" + (int)radius); } } public class Main { public static void main(String[] args) { Scanner s= new Scanner(System.in); Circle c [] = new Circle[3]; for(int i = 0; i < 3; i++) { System.out.print("x, y, radius >>"); double x = s.nextDouble(); double y = s.nextDouble(); double radius = s.nextDouble(); c[i] = new Circle(x,y,radius); } for(int i = 0; i < c.length; i++) { c[i].show(); } s.close(); } }
0
0
2
wimpy15
2020년 7월 28일
In 소스 코드 제출
/* import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int i, j = 0, arr[][] = new int [10][10]; int arr1[][] = new int [10][10]; int n = 0, p[][] = new int [8][2]; int k = 0; for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { arr[i][j] = scanner.nextInt(); arr1[i][j] = arr[i][j]; } } n = scanner.nextInt(); for(k = 0; k < n; k++) { p[k][0] = scanner.nextInt()-1; p[k][1] = scanner.nextInt()-1; } for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { if(arr[i][j]>=1) { for(k = 1; k<=arr[i][j]; k++) { if(i+k>9 || arr[i+k][j]==-1) { break; } arr1[i+k][j]=-2; } for(k = 1; k<=arr[i][j]; k++) { if(j+k>9 || arr[i][j+k]==-1) { break; } arr1[i][j+k]=-2; } for(k = 1; k<=arr[i][j] ;k++) { if(j-k<0 || arr[i][j-k]==-1) { break; } arr1[i][j-k]=-2; } for(k = 1; k<=arr[i][j] ;k++) { if(i-k<0 || arr1[i-k][j]==-1 ) { break; } arr1[i-k][j]=-2; } arr1[i][j]=-2; } } } for(k = 0; k<n ; k++) { if (arr1[ p[k][0] ][ p[k][1] ] == 0) { arr1[ p[k][0] ][ p[k][1] ] = k+1; } } for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { System.out.print(arr1[i][j]+" "); } System.out.println(); } System.out.println("Character Information"); for(k = 0; k < n; k++) { if(arr1[ p[k][0] ][ p[k][1] ] > 0) { System.out.println("player "+(k+1)+" survive"); } else { System.out.println("player "+(k+1)+" dead"); } } } } */ /* import java.util.Scanner; public class Main { public static void main(String[] args) { Tv t1 = new Tv(); Tv t2 = new Tv(); System.out.println("t1의 channel값은 " + t1.channel + "입니다"); System.out.println("t2의 channel값은 " + t2.channel + "입니다"); t1.channel = 7; System.out.println("t1의 channel값을 7로 변경하였습니다."); System.out.println("t2의 channel값은 "+ t1.channel + "입니다"); System.out.println("t2의 channel값은 "+ t2.channel + "입니다"); } } class Tv { String color; int channel; boolean power; void power() { power = !power;} void channelUP() { channel++; } void channelDown() { channel--; } } */ /* public class Main { public static void main(String[] args) { System.out.println("Card.width = "+ Card.width); System.out.println("Card.height ="+ Card.height); Card c1 = new Card(); c1.kind = "Heart"; c1.number = 7; Card c2 = new Card(); c2.kind = "Spade"; c2.number = 4; System.out.println("c1는 " + c1.kind + "," + c1.number +"이며, 크기는(" + c1.width +","+c1.height+")"); System.out.println("c2는 " + c2.kind + "," + c2.number +"이며, 크기는(" + c2.width +","+c2.height+")"); System.out.println("c1의 width와 height를 각각 50, 80으로 변경합니다"); c1.width = 50; c1.height = 80; System.out.println("c1는 " + c1.kind + "," + c1.number +"이며, 크기는(" + c1.width +","+c1.height+")"); System.out.println("c2는 " + c2.kind + "," + c2.number +"이며, 크기는(" + c2.width +","+c2.height+")"); } } class Card { String kind; int number; static int width = 100; static int height = 250; } */ import java.util.*; class subject { int a, b, c; subject() { a = 10; b = 20; c = 30; System.out.println("Here is Automactlly play"); } subject(int a, int b, int c) { this.a = a; this.b = b; this.c = c; System.out.println("WOW"); } void fuc() { System.out.println("asdassdasd"); } } class math extends subject { int p, k, z; } public class Main { public static void main(String[] args) { math m = new math(); } }
0
0
1
wimpy15
2020년 7월 25일
In 소스 코드 제출
import java.util.Scanner; /* public class Main { public static void main(String[] args) { System.out.print("ddfjdlksf"); } } */ public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int i, j = 0, arr[][] = new int [10][10]; int arr1[][] = new int [10][10]; int n = 0, p[][] = new int [4][4]; int k = 0; for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { arr[i][j] = scanner.nextInt(); arr1[i][j] = arr[i][j]; } } /////////////// for(k = 0; k < n; k++) { p[k][0] = scanner.nextInt()-1; p[k][1] = scanner.nextInt()-1; } for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { if(arr[i][j]>=1) { for(k = 1; k<=arr[i][j]; k++) { if(i+k>9 || arr[i+k][j]==-1) { break; } arr1[i+k][j]=-2; } for(k = 1; k<=arr[i][j]; k++) { if(j+k>9 || arr[i][j+k]==-1) { break; } arr1[i][j+k]=-2; } for(k = 1; k<=arr[i][j] ;k++) { if(j-k<0 || arr[i][j-k]==-1) { break; } arr1[i][j-k]=-2; } for(k = 1; k<=arr[i][j] ;k++) { if(i-k<0 || arr1[i-k][j]==-1 ) { break; } arr1[i-k][j]=-2; } arr1[i][j]=-2; } } } ///////////////////////////////// for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { System.out.print(arr1[i][j]+" "); } System.out.println("\n"); } System.out.println("Character Information"); for(k = 0; k < n ; k++) { if(arr1[p[k][0]][p[k][1]]==-2) { System.out.println("player "+(k+1)+" dead"); } else { System.out.println("player "+(k+1)+" survive"); } } } }
0
0
3
wimpy15
2020년 7월 21일
In 소스 코드 제출
#include <stdio.h> #define SIZE 5 int queue[SIZE]; int front; int rear; void queueinit() { front = 0; rear= 0; return; } void enqueue(int n) { if((rear+1)%SIZE ==front) { printf("queue is full\n"); return ; } rear = (rear+1)%SIZE; queue[rear] = n; return; } int dequeue() { int data; if((front == rear)) { printf("queue is empty\n"); return 0; } front = (front+1)%SIZE; data = queue[front]; queue[front] = 0; return data; } int main() { int i, gan, node ,j,x; int gm, sm; int arr[100][200], save[100]={0}; scanf("%d %d",&node,&gan); for(i = 0; i < stop; i++) { scanf("%d %d",&gm,&sm); arr[gm][sm]=1; } enqueue(1); /////////////////////////// while() { x = dequeue(); for(i = 1 ; i<=node ; i++) { if(arr[x][i]==1 && save[i]==0) { save[i]=1; enqueue(i); } } } for(i = 1; i <= stop; i++) { for(j = 1; j <= stop; j++) { printf("%d ",arr[i][j]); } printf("\n"); } /* for(i = 0; i < stop; i++) { for(j = 0; j < stop-1; j++) enqueue(int arr[1][2]) =1; enqueue(arr[2][1]) = 1; } } */ return 0; }
0
0
5
wimpy15
2020년 7월 19일
In 소스 코드 제출
//#include <stdio.h> //struct a //{ // int b, c; //}; // // //int main() //{ // int n, i, x; // struct a st[201]; // scanf("%d", &n); // for(i=1;i<=n;i++) // { // scanf("%d",&st[i].b); // } // for(i=1;i<=n;i++) // { // st[i].c=1; // for(int j=1;j<=n;j++) // { // if(st[j].b>st[i].b) // { // st[i].c++; // } // } // } // for(i=1;i<=n;i++) // { // printf("%d %d\n", st[i].b, st[i].c); // } // return 0; // //} #include <stdio.h> struct a { char b[11]; int c, d, e; }; int main() { struct a st[101]; int n, i,max=0,mm=0,k; scanf("%d", &n); for(i=1;i<=n;i++) { scanf("%s %d %d %d", st[i].b, &st[i].c, &st[i].d, &st[i].e); } for(i=1;i<=n;i++) { if(max<st[i].c) { max = st[i].c; mm = i; } } printf("%s ", st[mm].b); k=1; for(i=1;i<=n;i++) { if(st[mm].d<st[i].d) { k++; } } printf("%d ", k); k=1; for(i=1;i<=n;i++) { if(st[mm].e<st[i].e) { k++; } } printf("%d", k); return 0; }
0
0
2
wimpy15
2020년 7월 18일
In 소스 코드 제출
/* #include <stdio.h> #include <stdlib.h> int main() { printf("Hello world!\n"); return 0; } #include <stdio.h> struct competition { int country; int num; int score; }; int main() { int n, k, max= 0, max2 = 0, mm2= 0, i, j, mm = 0; int cnt = 0,d[101]={}; struct competition c[100]; scanf("%d",&n); for(k = 0; k < n; k++) { scanf("%d %d %d",&c[k].country,&c[k].num,&c[k].score); } for(i = 0 ; i < 5 ; i++) { max = 0; mm = 0; for(j = 0; j < n; j++) { if(max < c[j].score) { max = c[j].score; mm = j; } } c[mm].score = 0; d[c[mm].country]++; if(d[c[mm].country]==2) { for(j = 0; j<n ; j++) { if(c[j].country==c[mm].country) { c[j].score = 0; } } } printf("%d %d\n",c[mm].country,c[mm].num); } //i==2일 때, //1등 한 나라 == 2등 한 나라, 그 나라의 애들의 점수를 다 0점 처리 // 그리고 나서 3등 구하기 //각 나라별 획득 메달 수를 저장하는 배열 //금메달 딴 나라, 은메달 딴 나라 ++ // 나라별 획득 메달 수가 2개가 된 나라가 있으면 //그 나라의 점수들을 0점으로 처리 return 0; } */ /* #include <stdio.h> int main() { int i, j,a[101][101]={},x1,x2,y1,y2; int area = 1; for(i = 0; i < 4; i++) { scanf("%d %d %d %d",&x1,&x2,&y1,&y2); area=(x2-x1)*(y2-y1); printf("%d",area); } } */ /* #include <stdio.h> struct teacher { char name[11]; int score; } ; int main() { int n, m, max = 0, mm = 0; int i, j; struct teacher t[100]; scanf("%d %d",&n,&m); for(i = 0; i < n; i++) { scanf("%s %d",t[i].name,&t[i].score); } for(j = 0; j < m; j++) { max =0; mm = 0; for(i = 0; i < n; i++) { if(max < t[i].score) { max = t[i].score; mm = i; } } printf("%s\n",t[mm].name); t[mm].score = 0; } return 0; } */ /* #include <stdio.h> int main() { int m, n, i, j; scanf("%d %d",&m,&n); for(i = 0; i < n; i++) { for(j = 0; j < m; j++) { scanf("%d %d",&i,&j); } } for(i = 0; i < n; i++) { for(j = 0; j < m; j++) { if() } } } */ /* #include <stdio.h> int main() { int k,i, j,a[101][101]={},x1,x2,y1,y2,sum=0; for(k = 0; k < 4; k++) { scanf("%d %d %d %d",&x1,&y1,&x2,&y2); for(i = x1; i<x2; i++) { for(j = y1; j<y2; j++) { a[i][j] = 1; } } } for(i = 0 ; i<100 ; i++) { for(j = 0 ; j<100 ; j++) { sum+=a[i][j]; } } printf("%d",sum); return 0; } */ #include <stdio.h> int main() { int n, i, a[100001]={},k; scanf("%d",&n); for(i = 0; i < n; i++) { scanf("%d",&k); a[k]++; } for(k = 0; k<=100000; k++) { for(i = 0; i<a[k]; i++) { printf("%d ",k); } } return 0; }
0
0
2
wimpy15
2020년 7월 16일
In 소스 코드 제출
/* #include <stdio.h> #include <stdlib.h> int main() { printf("Hello world!\n"); return 0; } */ /* #include <stdio.h> #include <string.h> struct schedule { char name[99]; int day; }; swap(struct schedule *pa,struct schedule *pb) { struct schedule room; room = *pb; *pb = *pa; *pa = room; } int main() { int n,a,b,c,i,j,ret; struct schedule s[100]; scanf("%d",&n); for(i = 0; i < n; i++) { scanf("%s %d %d %d",s[i].name,&a,&b,&c); s[i].day = a*10000 + b*100 + c; } for(i = 0; i < n-1; i++) { for(j = 0; j < n-i; j++) { if(s[j].day < s[j+1].day) { swap(&s[j],&s[j+1]); } } } for(i = 0 ; i< n ; i++) { for(j= 0 ; j < n-i; j++) { if(s[j].day == s[j+1].day) { if(strcmp(s[j].name,s[j+1].name)==-1) { swap(&s[j],&s[j+1]); } } } } for(i = n-1; i >=0 ; i--) { printf("%s\n",s[i].name); } return 0; } */ #include <stdio.h> struct competition { int country; int num; int score; }; int main() { int n, k, max= 0, max2 = 0, mm2= 0, i, j, mm = 0; int cnt = 0,cc[3]={}; struct competition c[100]; scanf("%d",&n); for(k = 0; k < n; k++) { scanf("%d %d %d",&c[k].country,&c[k].num,&c[k].score); } for(i = 0 ; i < 3 ; i++) { if(i == 2 && cc[0]==cc[1]) { for(j = 0; j<n ; j++) { if(c[j].country==cc[0]) { c[j].score = 0; } } } max = 0; mm = 0; for(j = 0; j < n; j++) { if(max < c[j].score) { max = c[j].score; mm = j; } } c[mm].score = 0; cc[i]=c[mm].country; printf("%d %d\n",c[mm].country,c[mm].num); } //i==2일 때, //1등 한 나라 == 2등 한 나라, 그 나라의 애들의 점수를 다 0점 처리 // 그리고 나서 3등 구하기 //각 나라별 획득 메달 수를 저장하는 배열 //금메달 딴 나라, 은메달 딴 나라 ++ // 나라별 획득 메달 수가 2개가 된 나라가 있으면 //그 나라의 점수들을 0점으로 처리 return 0; }
0
0
3
wimpy15
2020년 7월 15일
In 소스 코드 제출
/* #include <stdio.h> #include <stdlib.h> int main() { printf("Hello world!\n"); return 0; } */ /* #include <stdio.h> int main() { int n, i ,t; int a[24]={}; scanf("%d",&n); for(i = 1; i <= n; i++) { scanf("%d",&t); a[t]+=1; } for(i = 1; i <=23; i++) { printf("%d ",a[i]); } return 0; } */ /* #include <stdio.h> int main() { int n, i, min; int a[10001] = {}; scanf("%d",&n); for(i = 1; i <= n; i++) { scanf("%d",&a[i]); } min=a[1]; for(i = 1; i <= n; i++) { if(min > a[i]) { min = a[i]; } } printf("%d",min); return 0; } */ /* #include <stdio.h> int main() { char name[20]; int i; scanf("%s",name); for(i = 0; name[i]; i++) { printf("%c",name[i] + 2); } printf("\n"); for(i = 0; name[i]; i++) { printf("%c",(name[i]*7)%80+48); } return 0; } */ /* #include <stdio.h> int main() { int n, k, i, a[100000]; scanf("%d %d",&n,&k); for(i = 1; i <= n; i++) { scanf("%d",&a[i]); } for(i = 1; i <= n; i++) { if(a[i] >= k) { printf("%d",i); return 0; } } printf("%d",n+1); return 0; } */ /* #include <stdio.h> int main() { int a[11][11], n, x, y; for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) { scanf("%d",&a[i][j]); } scanf("%d",&n); for(int k = 1; k <= n; k++) { scanf("%d %d",&x,&y); } for(int i = 0; i < 10; i++) { for(int j = 0; j < 10; j++) { if(a[i][j] >= 1) { } } } }*/ #include <stdio.h> #include <string.h> struct schedule { char name[99]; int day; }; swap(struct schedule *pa,struct schedule *pb) { struct schedule room; room = *pb; *pb = *pa; *pa = room; } swap1(char *pa,char *pb) { char room; room = *pb; *pb = *pa; *pa = room; } int main() { int n,a,b,c,i,j,ret; struct schedule s[100]; scanf("%d",&n); for(i = 0; i < n; i++) { scanf("%s %d %d %d",s[i].name,&a,&b,&c); s[i].day = a*10000 + b*100 + c; } for(i = 0; i < n-1; i++) { for(j = 0; j < n-i; j++) { if(s[j].day < s[j+1].day) { swap(&s[j],&s[j+1]); } } } for(i = 0 ; i< n ; i++) { for(j= 0 ; j < n-1; j++) { if(s[j].day == s[j+1].day) { if(strcmp(s[j].name,s[j+1].name)==1) { swap1(s[j].name,s[j+1].name); } } } } for(i = n-1; i >=0 ; i--) { printf("%s\n",s[i].name); } return 0; }
0
0
3
wimpy15
2020년 7월 14일
In 소스 코드 제출
/* #include <stdio.h> int map[101][101] = {0}; int black[101][101] = {0}; int white[101][101] = {0}; int black_cnt = 0; int white_cnt = 0; void off(int a,int b) { while(black[a][b+1] == 0 && black[a+1][b] == 0 &&black[a][b-1] == 0 && black[a-1][b] == 0) { if(black[a][b] == 0) { black[a][b+1] = 0; black[a+1][b] = 0; black[a][b-1] = 0; black[a-1][b] = 0; } if(black[a][b+1] == 0) { black[a+1][b+1] = 0; black[a][b+2] = 0; black[a-1][b+1] = 0; } if(black[a+1][b] == 0) { black[a+2][b] = 0; black[a+1][b-1] = 0; black[a+][b+1] = 0; } if(black[a][b-1] == 0) { black[] } } black_cnt++; } void on(int a, int b) { while(white[a][b+1] == 0 && white[a+1][b] == 0 &&white[a][b-1] == 0 && white[a-1][b] == 0) { if(white[a][b] == 1) { white[a][b+1] = 1; white[a+1][b] = 1; white[a][b-1] = 1; white[a-1][b] = 1; } } } int main() { int m, n; scanf("%d %d",&m,&n); for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { scanf("%d %d",&i,&j); } } printf("%d",black_cnt); return 0; } */ #include <stdio.h> int cnt = 0; int botton1(int k) { cnt++; return k += 1; } int botton2(int k) { cnt++; return k -= 1; } int botton3(int k) { cnt++; return k += 5; } int botton4(int k) { cnt++; return k -= 5; } int botton5(int k) { cnt++; return k += 10; } int botton6(int k) { cnt++; return k -= 10; } int main() { int a, b, c, d, e, f, g; scanf("%d %d",&a,&b); botton1(botton1( botton3(botton5(botton5(a))))); printf("%d",cnt); return 0; }
0
0
4

wimpy15

더보기