top of page

게시판 게시물

taejun4612
2022년 10월 11일
In 소스 코드 제출
/*#include <stdio.h> int main() { long long int a,s; scanf("%lld %lld",&a,&s); printf("%lld\n",a+s); printf("%lld\n",a-s); printf("%lld\n",a*s); printf("%lld\n",a/s); printf("%lld\n",a%s); printf("%.2f",(float)a/s); return 0; }*/ /*#include <stdio.h> int main() { long long int a,s,d; scanf("%lld %lld %lld",&a,&s,&d); printf("%lld\n",a+s+d); printf("%.1f",(a+s+d)/3.0); return 0; }*/ /*#include <stdio.h> int main() { int a,s; scanf("%d %d",&a,&s); printf("%d+%d=%d\n",a,s,a+s); printf("%d-%d=%d\n",a,s,a-s); printf("%d*%d=%d\n",a,s,a*s); printf("%d/%d=%d\n",a,s,a/s); return 0; }*/ /*#include <stdio.h> int main() { float a,s; scanf("%f %f",&a,&s); printf("%.2f",a*s); return 0; }*/ /*#include<stdio.h> int main() { int a; scanf("%d",&a); printf("%d %d",a/60, a%60); return 0; } 산술연산자 + - * / % 비교연산자 int a, b; scan- > < >= <= == != 비교연산의 결과는 1 또는 0으로 출력 a>b : a가 b보다 큰가요? (초과) a>=b : a가 b 이상인가요? (크거나같다) a=>b (x) a==b : a와 b가 같나요? (비교) a=b; a에 b를 대입하세요 (집어넣으세요) a != b : 다르다 a==b; (x) printf("%d",a==b); */ /*#include<stdio.h> int main() { int a,s; scanf("%d %d",&a,&s); printf("%d",a>s); return 0; }*/ /*#include<stdio.h> int main() { int a,s; scanf("%d %d",&a,&s); printf("%d",a==s); return 0; }*/ /*#include<stdio.h> int main() { int a,s; scanf("%d %d",&a,&s); printf("%d",a<=s); return 0; }*/ /*#include<stdio.h> int main () { int a,s; scanf("%d %d",&a,&s); printf("%d",a!=s); return 0; }*/ /*#include<stdio.h> int main () { int a; scanf("%d",&a); printf("%d",!a); return 0; }*/
0
0
6
taejun4612
2022년 10월 09일
In 소스 코드 제출
/* import java.util.*; public class Main{ public static void main(String[] args){ int a = 10; int b = 20; System.out.println(a); System.out.println(b); System.out.print("숫자는"+a+"입니다"); } } */ /* import java.util.*; class Circle{ int radius; String name; public double getArea() { return 3.14*radius*radius; } } class Main{ public static void main(String[] args) { Circle pizza; pizza = new Circle(); pizza.radius = 10; pizza.name = "자바피자"; double area = pizza.getArea(); System.out.println(pizza.name + "의 면적은 " + area); Circle donut; donut = new Circle(); donut.radius = 3; donut.name = "자바도넛"; double area1 = donut.getArea(); System.out.println(donut.name + "의 면적은 " + area1); } } */ /* import java.util.*; class Rectangle{ int width; int height; public int getArea() { return width*height; } } class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); Rectangle rec; rec = new Rectangle(); rec.width = sc.nextInt(); rec.height = sc.nextInt(); System.out.print("사각형의 넓이는 " + rec.getArea()); } } */ /* import java.util.*; class Circle{ int radius; String name; public Circle() { radius = 1; name = ""; } public Circle(int r, String n) { radius = r; name = n; } public double getArea() { return 3.14*radius*radius; } } class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); String t = sc.nextLine(); Circle pizza; pizza = new Circle(a,t); System.out.println(pizza.name + "의 면적은 "+pizza.getArea()); Circle donut; donut = new Circle(); System.out.print(donut.name+"의 면적은 "+donut.getArea()); } } */ /* import java.util.*; class Book{ String name; String author; public Book(String t) { name = t; author = "작자미상"; } public Book(String t, String a) { name = t; author = a; } } class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String title = sc.nextLine(); String wr = sc.nextLine(); Book b = new Book(title,wr); Book c = new Book("콩쥐팥쥐"); System.out.println(b.name + " " + b.author); System.out.print(c.name + " " + c.author); } } */ /* import java.util.*; class Circle{ int radius; public Circle(int radius) { this.radius = radius; } void set(int radius) { this.radius = radius; } } class Main{ public static void main(String[] args) { Circle c1 = new Circle(1); Circle c2 = new Circle(2); Circle c3 = new Circle(3); c1.set(4); c2.set(5); c3.set(6); System.out.println(c1.radius); System.out.println(c2.radius); System.out.println(c3.radius); } } */ /* import java.util.*; class Book{ String title; String author; void show() { System.out.println(title + " " + author); } public Book() { this("",""); System.out.println("생성자 호출됨"); } public Book(String t) { this(t,"작자미상"); } public Book(String t, String author) { this.title = t; this.author = author; } } class Main { public static void main(String[] args) { Book b1 = new Book("어린왕자","생텍쥐페리"); Book b2 = new Book("콩쥐팥쥐"); Book b3 = new Book(); b3.show(); } } */ /* import java.util.*; class Circle{ int radius; public Circle(int radius) { this.radius = radius; } public double getArea() { return 3.14*radius*radius; } } class Main{ public static void main(String[] args) { Circle[] c; c = new Circle[5]; for(int i=0;i<c.length;i++) { c[i] = new Circle(i); } for(int i=0;i<c.length;i++) { System.out.println(c[i].getArea()); } } } */ /* import java.util.*; class Book{ String title, author; public Book(String title, String author) { this.title = title; this.author = author; } } class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); Book[] book = new Book[2]; for(int i=0;i<book.length;i++) { System.out.println("제목>>"); String title = sc.nextLine(); System.out.println("저자>>"); String author = sc.nextLine(); book[i] = new Book(title,author); } for(int i=0;i<book.length;i++) { System.out.println(book[i].title + " , " + book[i].author); } } } */ /* import java.util.*; class ArrayPassing{ static void replaceSpace(char a[]) { for(int i=0;i<a.length;i++) { if(a[i]==' ') { a[i] = ','; } } } static void printCharArray(char a[]) { for(int i=0;i<a.length;i++) { System.out.print(a[i]); } System.out.println(); } } class Main{ public static void main(String[] args) { char c[] = {'T','h','i','s',' ','i','s',' ','a',' ','P','e','n','c','i','l'}; ArrayPassing ap = new ArrayPassing(); ap.printCharArray(c); ap.replaceSpace(c); ap.printCharArray(c); } } */ /* import java.util.*; class MethodSample{ public int getSum(int i, int j) { return i+j; } public int getSum(int i, int j, int k){ return i+j+k; } public double getSum(double i, double j) { return i+j; } } class Main{ public static void main(String[] args) { MethodSample ms = new MethodSample(); int a = ms.getSum(1, 2); int b = ms.getSum(1, 2, 3); double c = ms.getSum(1.1, 2.2); System.out.println(a); System.out.println(b); System.out.println(c); } } */ /* import java.util.*; class Samp{ int id; public Samp(int x) { this.id = x; } public void set(int x) { this.id = x; } public int get() { return id; } } class Main{ public static void main(String[] args) { Samp ob1 = new Samp(3); Samp ob2 = new Samp(4); Samp s; s = ob2; ob1 = ob2; System.out.println(ob1.get()); System.out.println(ob2.get()); System.out.println(s.get()); } } */ /* import java.util.*; class Sample{ public int a; private int b; int c; } public class Main { public static void main(String[] args) { Sample sample = new Sample(); sample.a = 10; sample.b = 10; sample.c = 10; System.out.println(sample.a); System.out.println(sample.b); System.out.println(sample.c); } } */ /* import java.util.*; class Calc{ public static int abs(int a) { return a>0? a:-a; } public static int max(int a, int b) { return (a>b)?a:b; } public static int min(int a, int b) { return (a>b)?b:a; } } public class Main{ public static void main(String[] args) { System.out.println(Calc.abs(-5)); System.out.println(Calc.max(10, 8)); System.out.println(Calc.min(-3, -8)); } } */ /* import java.util.*; class Song{ String name; public Song(String name) { this.name = name; } public String getTitle() { return name; } } class Main{ public static void main(String[] args) { Song mysong = new Song("Nessun Dorma"); Song yoursong = new Song("공주는 잠 못 이루고"); System.out.println(mysong.getTitle()); System.out.println(yoursong.getTitle()); } } */ /* import java.util.*; class Phone{ private String name, tel; public Phone(String name, String tel) { this.name = name; this.tel = tel; } public String getName() { return name; } public String getTel() { return tel; } } class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); Phone ph1, ph2; String name1,tel1; String name2, tel2; System.out.println("이름과 전화번호 입력 >>"); name1 = sc.nextLine(); tel1 = sc.nextLine(); ph1 = new Phone(name1,tel1); System.out.println("이름과 전화번호 입력 >>"); name2 = sc.nextLine(); tel2 = sc.nextLine(); ph2 = new Phone(name2,tel2); System.out.println(ph1.getName()+" "+ph1.getTel()); System.out.println(ph2.getName()+" "+ph2.getTel()); } } */ import java.util.*;
0
0
1
taejun4612
2022년 9월 04일
In 소스 코드 제출
/* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int arr[][] = new int[a][a]; for(int i=0;i<a;i++) { arr[i][0] = sc.nextInt(); } for(int i=1;i<a;i++) { for(int f=1;f<=i;f++) { arr[i][f] = arr[i][f-1] - arr[i-1][f-1]; } } for(int i=0;i<a;i++) { for(int f=0; f<=i;f++) { System.out.print(arr[i][f]+" "); } System.out.println(); } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); char arr[] = s.toCharArray(); for(int i=0; i<arr.length;i++) { if(arr[i]>='a'&&'z'>=arr[i]) { System.out.print(arr[i]-32); } else if(arr[i]>='A'&&arr[i]<='Z') { System.out.print(arr[i]+32); } else { System.out.print(arr[i]); } } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); char arr[] = s.toCharArray(); for(int i=0;i<arr.length;i++) { if(arr[i]<='z'&&arr[i]>='a') { System.out.print((char)(arr[i]-' ')); } else if(arr[i]<='Z'&&arr[i]>='A') { System.out.print((char)(arr[i]+' ')); } else { System.out.print(arr[i]); } } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int arr[][] = new int [11][11]; for(int i=1;i<=9;i++) { for(int f=1;f<=9;f++) { arr[i][f] = sc.nextInt(); } } int x = sc.nextInt(); int y = sc.nextInt(); int t=0; if(arr[x][y]==0) { for(int i=x-1;i<=x+1;i++) { for(int f=y-1;f<=y+1;f++) { if(arr[i][f]==1) { t++; } } } System.out.println(t); } else { System.out.println(-1); } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int t=0; char arr[] = s.toCharArray(); for(int i=0;i<arr.length;i++) { t += arr[i]-48; } if(t%3==0) { System.out.println(1); } else { System.out.println(0); } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s1 = sc.next(); String s2 = sc.next(); String s3 = sc.next(); if(s1.charAt(s1.length()-1)==s2.charAt(0)&&s2.charAt(s2.length()-1)==s3.charAt(0)&&s3.charAt(s3.length()-1)==s1.charAt(0)) { System.out.println("good"); } else { System.out.println("bad"); } } } c 절차지향언어 java 객체지향언어 oop object oriendted programming 클래스 : 틀 ( 필드, 생성자, 메소드) 객체 : 틀로 찍어낸 물체 */ /* import java.util.*; class Person{ //필드 int age; String name; //생성자 객체 생성시 한 번만 호출 ( 초기값설정) Person(){ // age=1000; // name="미정"; this(1000,"미정"); } Person(int age){ // this.age=age; // this.name = "미정"; this(age,"미정"); } Person(int age, String name){ this.age=age; this.name=name; } //메소드 void speak() { System.out.println("안녕하세요 저는 "+name+"입니다."); System.out.println("나이는 "+age+"살 입니다."); } } class Main{ public static void main(String[] args) { //Person p; //레퍼런스변수 생성 (아직 객체생성 x) //p = new Person(); Person p = new Person(); p.age=10; p.speak(); Person s = new Person(50); s.speak(); Person q = new Person(100,"이태준"); q.speak(); } } */ /* import java.util.*; class Song{ String name; Song(String name){ this.name = name; } String getTitle() { return name; } } class Main{ public static void main(String[] args) { Song mysong = new Song("Nessun Dorma"); Song yoursong = new Song("공주는 잠 못 이루고"); System.out.println("내 노래는 "+mysong.getTitle()); System.out.println("네 노래는 "+yoursong.getTitle()); } } */ /* import java.util.*; class Phone{ static int num=0; private St ring name, tel; public Phone() { // TODO Auto-generated constructor stub } public Phone(String name, String tel) { this.name = name; this.tel = tel; } public static void setNum(int n) { num=n; //name="이름"; } public String getName() { num++; return name; } public String getTel() { return tel; } } class Main{ public static void main(String[] args) { Phone.num++; System.out.println(Phone.num); // Phone a = new Phone(); // Phone b = new Phone(); // a.num++; // System.out.println(b.num); //Phone.num //int arr[] = new int[5]; //Phone arr[] = new Phone[5]; //System.out.println(arr[0].getName()); // for(int i=0;i<arr.length;i++) { // arr[i] = new Phone("이름","tel"); // } // Scanner sc = new Scanner(System.in); // System.out.println("이름과 전화번호를 입력>>"); // String name1 = sc.next(); // String tel1 = sc.next(); // Phone p1 = new Phone(name1,tel1); // System.out.println("이름과 전화번호 입력>>"); // String name2 = sc.next(); // String tel2 = sc.next(); // Phone p2 = new Phone(name2, tel2); // System.out.println(p1.getName()+"의 번호 "+p1.getTel()); // System.out.println(p2.getName()+"의 번호 "+p2.getTel()); } } */ /* import java.util.*; class Circle { private int radius; public Circle(int radius) { this.radius = radius; } public int getRadius() { return this.radius; } public void setRadius(int radius) { this.radius = radius; } } class CircleManager{ public static void copy(Circle src, Circle dest) { dest.setRadius(src.getRadius()); } public static boolean equals(Circle a, Circle b) { if(a.getRadius()==b.getRadius()) { return true; } else { return false; } } } 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.*; class Box{ private int width, height; private char filchar; public Box() { this(10,1); } public Box(int width, int height) { this.height = height; this.width = width; } public void draw() { for(int i=0;i<height;i++) { for(int f=0;f<width;f++) { System.out.print(filchar); } System.out.println(); } } public void fill(char c) { this.filchar = c; } } class Main{ public static void main(String[] args) { Box a = new Box(); Box b = new Box(20,3); a.fill('*'); b.fill('%'); a.draw(); b.draw(); } }*/ /* import java.util.*; class Person{ //필드 private int age; private String name; //생성자 객체 생성시 한 번만 호출 ( 초기값설정) Person(){ this(1000,"미정"); } Person(int age, String name){ this.age=age; this.name=name; } //메소드 void speak() { System.out.println("안녕하세요 저는 "+name+"입니다."); System.out.println("나이는 "+age+"살 입니다."); } } class Student extends Person{ String school; Student(int age, String name, String sch){ super(age,name); this.school = sch; } void speak() { System.out.println("저는 학생입니다."); } void speak(int n) { System.out.println("nnn"); } } class Teacher extends Person{ String sub; } class Main{ public static void main(String[] args) { Student s = new Student(10,"fff","jjj"); s.speak(4); } } */ import java.util.*; /* abstract class Circle { private int radius; public Circle(int radius) { this.radius = radius; } public int getRadius() { return radius; } abstract void show(); } */ interface Circle{ abstract void show(); // default void view() { // System.out.println(); // } } interface Circle2{ } abstract class NamedCircle implements Circle,Circle2{ //extends Circle{ private String name; NamedCircle(int r, String name){ super(r); this.name = name; } // void show() { // System.out.println(name+", "+"반지름 = "+getRadius()); // } } class Main{ public static void main(String[] args) { NamedCircle w = new NamedCircle(5,"waffle"); w.show(); } }
0
0
6
taejun4612
2022년 9월 03일
In 소스 코드 제출
/* import java.util.*; //함수 == 메소드 // ctrl + space (자동완성) // compile ctrl + f11 // syso + 자동완성 (출력) public class Main { public static void main(String[] args) { // 기본 자료형 // int a=10; // long b=100; // not long long int // float c; // double d; // char f; // boolean e; // true or false // String str="hello"; // System.out.print(str); // System.out.println(str); // System.out.println("문자열은"+str+"입니다."); // System.out.println(a+" 입니다"); // System.out.println(a+" "+b); // 산술연산자 : + - * / % // 비교연산자 : > < >= <= == != // 논리연산자 : ! && || 비트논리연산자 : ~ & | // System.out.println(a*b); // 조건문 if-else switch-case // 반복문 for, while, do-while // while(true) { // //// } // if(){ // } // int a[5] //(x) // int[] arr1; // 배열의 주소값을 저장하는 레퍼런스변수 생성 // arr1 = new int[5]; // 실제 배열 생성 // // int[] arr = new int [a]; // int[] arr2 = {1,2,3,4,5}; // // for(int i=0;i<arr2.length;i++) { // System.out.print(arr2[i]+" "); // } // // int[][] arr3 = new int[a][a]; // int[][] arr4 = {{1,2,3},{4,5,6}}; /////////////////////////////////// // 1. 스캐너 객체 생성 Scanner sc = new Scanner(System.in); // int a = sc.nextInt(); // System.out.println(a); // float b = sc.nextFloat(); // System.out.println(b); //String s = sc.next(); //공백 x //String s = sc.nextLine(); // 공백 o // System.out.println(s); // System.out.println("length : " + s.length()); // System.out.println(s.charAt(0)); // char[] arr = s.toCharArray(); // string -> char arr // System.out.println(arr[0]); //System.out.println(s.compareTo("jello world")); // 문자열의 사전식비교 //if(s=="hello") (x) // if(s.equals("hello")) { //문자열끼리 비교시 == 불가능 !! // System.out.println("same"); // } //String s1 = s.replace('h', 'e'); //String s1 = s.toUpperCase(); //String s1 = s.toLowerCase(); // String s = "hello,world hi,hi hello,hihi"; // String[] s1 = s.split(","); // for(int i=0; i<s1.length;i++) { // System.out.println(s1[i]); // } } } a,b, c a+b>c b+c>a a+c>b */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if(a>b&&a>c) { if(a<b+c) { System.out.println("yes"); } else { System.out.println("no"); } } else if(b>c&&b>a) { if(b<a+c) { System.out.println("yes"); } else { System.out.println("no"); } } else { if(c<a+b) { System.out.println("yes"); } else { System.out.println("no"); } } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if(c<a+b) { if(a==b&&b==c) { System.out.println("정삼각형"); } else if(a==b||a==c||b==c) { System.out.println("이등변삼각형"); } else if((a*a)+(b*b)==(c*c)) { System.out.println("직각삼각형"); } else if(c<a+b) { System.out.println("삼각형"); } } else { System.out.println("삼각형아님"); } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int t = 170; if(a<=t) { System.out.println("CRASH"+" "+a); } if(a>t&&b<=t) { System.out.println("CRASH"+" "+b); } if(a>t&&b>t&&c<=t) { System.out.println("CRASH"+" "+c); } if(a>t&&b>t&&c>t) { System.out.println("PASS"); } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); for(int i=1; i<=a;i++) { System.out.print(i+" "); } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); for(int i=a;i<=b;i++) { if(i%2==1) { System.out.print(i+" "); } } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int t=1; for(int i=a;i>0;i--) { t=t*i; } System.out.println(t); } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int t = 0; for(int i=a;i<=b;i++) { if(i%2==1) { t = t+i; } else { t = t-i; } } System.out.println(t); } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); for(int i=0;i<a;i++) { for(int f=0;f<i;f++) { System.out.print(" "); } for(int f=a;f>i;f--) { System.out.print("*"); } System.out.println(); } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); for(int i=0;i<a;i++) { for(int f=a-1;f>i;f--) { System.out.print(" "); } for(int f=0;f<a;f++) { System.out.print("*"); } System.out.println(); } } } 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int arr[] = new int[a]; for(int i=0;i<a;i++) { arr[i] = sc.nextInt(); } for(int i=0;i<a;i++) { for(int f=i;f<i+a;f++) { System.out.print(arr[f%a]+" "); } System.out.println(); } } } */ /* import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); char[] arr = s.toCharArray(); int a=0,b=0; for(int i=0;i<arr.length;i++) { if(arr[i]=='(') { a++; } else { b++; } } System.out.println(a+" "+b); } } */ import java.util.*; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int arr[] = new int[a]; for(int i=0;i<a;i++) { arr[i] = sc.nextInt(); } for(int i=0;i<a;i++) { System.out.print(i+1+": "); for(int f=0;f<a;f++) { if(i!=f) { if(arr[i]<arr[f]) { System.out.print("< "); } else if(arr[i]==arr[f]) { System.out.print("= "); } else { System.out.print("> "); } } } System.out.println(); } } }
0
0
10
taejun4612
2022년 8월 20일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> using namespace std; int main() { cout.put('H'); cout.put('i'); cout.put(33); cout.put('\n'); cout.put('C').put('+').put('+').put(' '); char str[] = "I love programming"; cout.write(str,10); } */ /* #include<iostream> using namespace std; void get1() { cout << "cin.get()로 <ENTER>키까지 입력받고 출력합니다>>"; int ch; while((ch = cin.get()) != EOF) { cout.put(ch); if(ch == '\n') break; } } void get2() { cout << "cin.get(char&)로 <ENTER> 키까지 입력받고 출력합니다>>"; char ch; while(true) { cin.get(ch); if(cin.eof()) break; cout.put(ch); if(ch == '\n') break; } } int main() { get1(); get2(); } */ /* #include<iostream> #include<cstring> using namespace std; int main() { char cmd[80]; cout << "cin.get(char*, int)로 문자열을 읽습니다." << endl; while(true) { cout << "종료하려면 exit을 입력하세요 >>"; cin.get(cmd, 80); if(strcmp(cmd, "exit") == 0) { cout << "프로그램을 종료합니다..."; return 0; } else cin.ignore(1); } } */ /* #include<iostream> #include<cstring> using namespace std; int main() { char line[80]; cout << "cin.getline() 함수로 라인을 읽습니다." << endl; cout << "exit을 입력하면 루프가 끝납니다." << endl; int no = 1; while(true) { cout << "라인" << no << ">>"; cin.getline(line,80); if(strcmp(line, "exit") == 0) { break; } cout << "echo -->"; cout << line << endl; no++; } } */ /* #include<iostream> using namespace std; int main() { cout << 30 << endl; cout.unsetf(ios::dec); cout.setf(ios::hex); cout << 30 << endl; cout.setf(ios::showbase); cout << 30 << endl; cout.setf(ios::uppercase); cout << 30 << endl; cout.setf(ios::dec| ios:: showpoint); cout << 23.5 << endl; cout.setf(ios::scientific); cout << 23.5 << endl; cout.setf(ios::showpos); cout << 23.5 << endl; } */ /* #include<iostream> using namespace std; void showWidth() { cout.width(10); cout << "Hello" << endl; cout.width(5); cout << 12 << endl; cout << "%"; cout.width(10); cout << "Korea"; } int main() { showWidth(); cout << endl; cout.fill('&'); showWidth(); cout << endl; cout.precision(5); cout << 11./3. << endl; } */ /* #include<iostream> #include<iomanip> using namespace std; int main() { cout << showbase; cout << setw(8) << "Number"; cout << setw(10) << "Octal"; cout << setw(10) << "Hexa" << endl; for(int i=0;i<50;i+=5) { cout << setw(8) << setfill('.') << dec << i; cout << setw(10) << setfill(' ') << oct << i; cout << setw(10) << setfill(' ') << hex << i << endl; } } */ #include<iostream> using namespace std; class Point{ int x, y; public: Point(int x=0, int y=0) { this-> x = x; this-> y = y; } friend ostream& operator << (ostream& stream, Point a); }; ostream& operator << (ostream& stream, Point a) { stream << "(" << a.x << "," << a.y << ")"; return stream; } int main() { Point p(3,4); cout << p << endl; Point q(1,100), r(2, 200); cout << q << r << endl; }
0
0
2
taejun4612
2022년 8월 18일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> #include<string> #include<map> using namespace std; int main() { map<string, string> dic; cout << "***암호관리 프로그램 WHO를 시작합니다***" << endl; int n; while(true) { string name, pw; cout << "삽입:1, 검사:2, 종료:3>>"; cin >> n; if(n==1) { cout << "이름 암호>>"; cin >> name >> pw; dic.insert(make_pair(name,pw)); } else if(n==2) { cout << "이름?"; cin >> name; if(dic.find(name)==dic.end()) { cout<< "실패~~" << endl; } else { cout << "암호?"; cin >> pw; if(dic[name] == pw) { cout << "통과!!" << endl; } else { cout << "실패~~" << endl; } } } } else { cout << "프로그램을 종료합니다..." << endl; break; } } } */ /* #include<iostream> #include<string> #include<map> using namespace std; int main() { map<string, string> dic; cout << "***암호관리 프로그램 WHO를 시작합니다***" << endl; int n; while(true) { string name, pw; cout << "삽입:1, 검사:2, 종료:3>>"; cin >> n; if(n==1) { cout << "이름 암호>>"; cin >> name >> pw; dic.insert(make_pair(name,pw)); } else if(n==2) { while(true) { cout << "이름?"; cin >> name; if(dic.find(name)==dic.end()) { cout<< "실패~~" << endl; } else { while(true) { cout << "암호?"; cin >> pw; if(dic[name] == pw) { cout << "통과!!" << endl; break; } else { cout << "실패~~" << endl; } } break; } } } else { cout << "프로그램을 종료합니다..." << endl; break; } } } */ #include<iostream> #include<vector> #include<string> using namespace std; class Circle{ string name; int radius; public: Circle(int radius, string name) { this->radius = radius; this->name = name; } double getArea() { return 3.14*radius*radius; } string getName() { return name; } }; int main() { vector<Circle> v; vector<Circle>::iterator it; cout << "원을 삽입하고 삭제하는 프로그램입니다." << endl; while(true) { string circle; int r,n; cout << "삽입:1, 삭제:2, 모두보기:3, 종료:4 >>"; cin >> n; if(n==1) { cout << "생성하고자 하는 원의 반지름과 이름은 >>"; cin >> r >> circle; Circle x(r,circle); v.push_back(x); } else if(n==2) { cout << "삭제하고자 하는 원의 이름은 >>"; cin >> circle; for(it=v.begin();it!=v.end(); ) { //cout << "*" << it->getName() << endl; if(circle==it->getName()) { cout << "*" << it->getName() << endl; it = v.erase(it); if(it==v.end()) { break; } } else{ it++; } } } else if(n==3) { for(it=v.begin();it!=v.end();it++) { cout << it->getName() << endl; } } else { cout << "프로그램을 종료합니다..." << endl; break; } } }
0
0
2
taejun4612
2022년 8월 17일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> using namespace std; class Circle{ int radius; public: Circle(int radius=1) {this->radius = radius;} int getRadius() {return radius;} }; template<class T> T bigger(T a, T b) { if(a > b) return a; else return b; } int main() { int a = 20, b = 50, c; c = bigger(a,b); cout << "20과 50 중 큰 값은" << c << endl; Circle waffle(10), pizza(20), y; y = bigger(waffle, pizza); cout << "waffle과 pizza 중 큰 것의 반지름은" << y.getRadius() << endl; } */ /* #include<iostream> #include<vector> using namespace std; int main() { vector<int> v; int sum=0; for(int i=0; i<10; i++) { int n; cout << "정수를 입력하세요(0을 입력하면 종료)>>"; cin >> n; if(n == 0) { break; } else { v.push_back(n); for(int i=0; i<v.size(); i++) { cout << v[i] << " "; sum+=v[i]; } cout << endl; cout << "평균 = " << sum/v.size() << endl; } } } */ /* #include<iostream> #include<vector> #include<string> using namespace std; class Book{ public: string book, name; int y; Book(string book, string name, int y) { this->book = book; this->name = name; this->y = y; } string getBook() { return book; } string getName() { return name; } int getYear() { return y; } }; int main() { vector<Book> v; int i; cout << "입고할 책을 입력하세요. 년도에 -1을 입력하면 입고를 종료합니다." << endl; for(i=0; i<10; i++) { string book1, name1; int y1; cout << "년도>>"; cin >> y1; if(y1==-1) { break; } else { cout << "책이름>>"; cin >> book1; cout << "저자>>"; cin >> name1; Book x(book1, name1, y1); v.push_back(x); } } cout << "총 입고된 책은 " << i << "권입니다." << endl; vector<Book>::iterator it; string writer; cout << "검색하고자 하는 저자의 이름을 입력하세요>>"; cin >> writer; for(it=v.begin();it!=v.end();it++) { string name; name = it->getName(); if(writer==name) { cout << it->getYear() << "년도, " << it->getBook() << ", " << name << endl; } } int year; cout << "검색하고자 하는 년도를 입력하세요>>"; cin >> year; for(it=v.begin();it!=v.end();it++) { int y; y = it->getYear(); if(y == year) { cout << year << "년도, " << it->getBook() << ", " << it->getName() << endl; } } } */ /* #include<iostream> #include<map> #include<string> using namespace std; int main() { map<string, int> dic; cout << "***점수관리 프로그램 HIGH SCORE을 시작합니다***" << endl; while(true) { int n,s; string name; cout << "입력:1, 조회:2, 종료:3 >>"; cin >> n; if(n==1) { cout << "이름과 점수>> "; cin >> name >> s; dic.insert(make_pair(name,s)); } else if(n==2) { cout << "이름>> "; cin >> name; cout << name << "의 점수는 " << dic[name] << endl; } else { cout << "프로그램을 종료합니다..." << endl; break; } } } */ #include<iostream> #include<string> #include<map> using namespace std; int main() { map<string, string> dic; cout << "***암호관리 프로그램 WHO를 시작합니다***" << endl; int n; while(true) { string name, pw; cout << "삽입:1, 검사:2, 종료:3>>"; cin >> n; if(n==1) { cout << "이름 암호>>"; cin >> name >> pw; dic.insert(make_pair(name,pw)); } else if(n==2) { cout << "이름?"; cin >> name; if(dic.find(name)==dic.end()) { cout<< "실패~~" << endl; } else { cout << "암호?"; cin >> pw; if(dic[name] == pw) { cout << "통과!!" << endl; } else { cout << "실패~~" << endl; } } } else { cout << "종료합니다..." << endl; } } }
0
0
2
taejun4612
2022년 8월 16일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> #include<vector> using namespace std; int main() { vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); for(int i=0;i<v.size();i++) { cout << v[i] << " "; } cout << endl; v[0] = 10; int m = v[2]; v.at(2) = 5; for(int i=0;i<v.size();i++) { cout << v[i] << " "; } cout << endl; } */ /* #include<iostream> #include<vector> using namespace std; int main() { vector<int> v; vector<int>::iterator it; v.push_back(1); v.push_back(2); v.push_back(3); it = v.begin(); it = v.insert(it,10); for(int i=0; i<v.size();i++) { cout << v[i] << " "; } cout << endl; v.erase(); } */ /* #include<iostream> #include<vector> #include<string> using namespace std; int main() { vector<string> sv; string name; cout << "이름을 5개 입력하라" << endl; for(int i=0; i<5;i++) { cout << i+1 << ">>"; getline(cin, name); sv.push_back(name); } name = sv.at(0); for(int i=1;i<sv.size();i++) { if(name<sv[i]) name = sv[i]; } cout << "사전에서 가장 뒤에 나오는 이름은 " << name << endl; } */ /* #include<iostream> #include<vector> using namespace std; int main() { vector<int>::iterator it; vector<int> v; for(int i=0;i<5;i++) { v.push_back(i+1); } it = v.begin(); it++; int n = *it; n = n*2; *it = n; for(it=v.begin();it!=v.end();it++) { int t = *it; cout << t << endl; } } */ /* #include<iostream> #include<vector> using namespace std; int main() { vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); vector<int>::iterator it; for(it=v.begin();it!=v.end();it++) { int n = *it; n = n*2; *it = n; } for(it=v.begin();it!=v.end();it++) { cout << *it << " "; } cout << endl; } */ /* #include<iostream> #include<string> #include<map> using namespace std; int main() { map<string, string> dic; dic.insert(make_pair("love", "사랑")); dic.insert(make_pair("apple", "사과")); dic["cherry"] = "체리"; cout << "지정된 단어의 개수" << dic.size() << endl; string eng; while(true) { cout << "찾고싶은 단어>>"; getline(cin,eng); if(eng == "exit") { break; } if(dic.find(eng)==dic.end()) { cout << "없음" << endl; } else { cout << dic[eng] << endl; } } cout << "종료합니다." << endl; } */ /* #include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { vector<int> v; cout << "정수를 5개 입력하세요>>"; for(int i=0;i<5;i++) { int n; cin >> n; v.push_back(n); } sort(v.begin(),v.end()); vector<int>::iterator it; for(it=v.begin();it!=v.end();it++) { cout << *it << " "; } cout << endl; } */ /* #include<iostream> #include<vector> using namespace std; int square(int x) { return x*x; } int main() { auto c = 'a'; auto pi = 3.14; auto ten = 10; auto *p = &ten; cout << c << " " << pi << " " << ten << " " << *p << endl; auto ret = square(3); cout << *p << " " << ret << endl; vector<int> v = {1,2,3,4,5}; vector<int>::iterator it; for(it=v.begin();it!=v.end();it++) { cout << *it << " "; } cout << endl; for(auto it = v.begin();it!=v.end();it++) { cout << *it << " "; } } */ /* #include<iostream> using namespace std; int main() { [](int x, int y){cout << "합은 " << x+y;} (2, 3); } */ /* #include<iostream> #include<string> using namespace std; int main() { auto love = [](string a, string b){cout << a << "보다 " << b <<"가 좋아."<< endl;}; love("돈", "너"); love("냉면","만두"); } */ /* #include<iostream> using namespace std; int main() { double pi = 3.14; auto calc = [pi](int r) -> double{return pi*r*r;}; cout << "면적은 " << calc(3) << endl; } */
0
0
3
taejun4612
2022년 8월 11일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> #include<string> using namespace std; class Converter{ protected: double ratio; virtual double convert(double src)=0; virtual string getSourceString()=0; virtual string getDestString()=0; public: Converter(double ratio) { this->ratio = ratio; } void run() { double src; cout << getSourceString() << "을" << getDestString() << "로 바꿉니다. "; cout << getSourceString() << "을 입력하세요."; cin >> src; cout << "변환결과 : " << convert(src) << getDestString() << endl; } }; class WonToDollar : public Converter{ protected: virtual double convert(double src) { return src/ratio; } virtual string getSourceString() { return "원"; } virtual string getDestString() { return "달러"; } public: WonToDollar(double ratio): Converter(ratio) {} }; int main() { WonToDollar wd(1010); wd.run(); } */ /* #include<iostream> #include<string> using namespace std; class Converter{ protected: double ratio; virtual double convert(double src)=0; virtual string getSourceString()=0; virtual string getDestString()=0; public: Converter(double ratio) { this->ratio = ratio; } void run() { double src; cout << getSourceString() << "을 " << getDestString() << "로 바꿉니다."; cout << getSourceString() << "을 입력하세요>>"; cin >> src; cout << "변환결과 : " << convert(src) << getDestString() << endl; } }; class KmToMile : public Converter{ protected: virtual double convert(double src) { return src/ratio; } virtual string getSourceString() { return "Km"; } virtual string getDestString() { return "Mile"; } public: KmToMile(double ratio) : Converter(ratio) {} }; int main() { KmToMile toMile(1.609344); toMile.run(); } */ /* #include<iostream> #include<string> using namespace std; class LoopAdder{ string name; int x,y,sum; void read(); void write(); protected: LoopAdder(string name="") { this->name = name; } int getX() {return x;} int getY() {return y;} virtual int calculate()=0; public: void run(); }; void LoopAdder::read() { cout << name << ":" << endl; cout << "처음 수에서 두번쨰 수까지 더합니다. 두 수를 입력하세요 >> "; cin >> x >> y; } void LoopAdder::write() { cout << x << "에서 " << y << "까지의 합 = " << sum << " 입니다." << endl; } void LoopAdder::run() { read(); sum = calculate(); write(); } class ForLoopAdder : public LoopAdder{ protected: virtual int calculate() { int t=0; for(int i=getX(); i<=getY(); i++) { t+=i; } return t; } public: ForLoopAdder(string name) : LoopAdder(name) {} }; int main() { ForLoopAdder forLoop("For Loop"); forLoop.run(); } */ /* #include<iostream> using namespace std; class AbstractGate{ protected: bool x,y; public: void set(bool x, bool y) { this->x = x; this->y = y; } virtual bool operation()=0; }; class ANDGate : public AbstractGate{ public: virtual bool operation() { return (x&&y); } }; class ORGate : public AbstractGate{ public: virtual bool operation() { return (x||y); } }; class XORGate : public AbstractGate{ public: virtual bool operation() { if((x&&y)==1) { return 0; } else { return 1; } } }; int main() { ANDGate andGate; ORGate orGate; XORGate xorGate; andGate.set(true, false); orGate.set(true, false); xorGate.set(true, false); cout.setf(ios::boolalpha); cout << andGate.operation() << endl; cout << orGate.operation() << endl; cout << xorGate.operation() << endl; } /* #include <iostream> using namespace std; int main() { bool x, y; x = true; y = true; cout << (x && y) << endl; } */ /* #include<iostream> #include<vector> using namespace std; int main() { vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); for(int i=0; i<v.size(); i++) { cout << v[i] << " "; } cout << endl; v[0] = 10; int m = v[2]; v.at(2) = 5; for(int i=0; i<v.size(); i++) { cout << v[i] << " "; } cout << endl; } */ #include<iostream> #include<string> #include<vector> using namespace std; int main() { vector<string> sv; string name; cout << "이름을 5개 입력하라" << endl; for(int i=0; i<5;i++) { cout << i+1 << ">>"; getline(cin,name); sv.push_back(name); } name = sv.at(0); for(int i=0;i<sv.size();i++) { if(name<sv[i]) { name = sv[i]; } } cout << "사전에서 가장뒤 나오는 이름은 "<< name << endl; }
0
0
3
taejun4612
2022년 8월 09일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> using namespace std; class Base{ public: void f() { cout << "Base::f() called" << endl; } }; class Derived : public Base{ public: void f() { cout << "Derived::f() called" << endl; } }; int main() { Derived d, *pDer; pDer = &d; pDer->f(); Base* pBase; pBase = pDer; pBase->f(); } */ /* #include<iostream> using namespace std; class Base{ public: virtual void f() { cout << "Base::f() called" << endl; } }; class Derived : public Base{ public: virtual void f() { cout << "Derived::f() called" << endl; } }; int main() { Derived d, *pDer; pDer = &d; pDer->f(); Base *pBase; pBase = pDer; pBase->Base::f(); } */ /* #include<iostream> using namespace std; class Shape{ public: virtual void draw() { cout << "Shape::draw() called" << endl; } }; class Circle : public Shape{ public: virtual void draw() { cout << "Circle::draw() called" << endl; } }; class Rect : public Shape{ public: virtual void draw() { cout << "Rect::draw() called" << endl; } }; class Line : public Shape{ public: virtual void draw() { cout << "Line::draw() called" << endl; } }; void paint(Shape* p) { p->draw(); } int main() { paint(new Rect); paint(new Circle); paint(new Line); } */ /* #include<iostream> using namespace std; class Shape{ public: void paint() { draw(); } virtual void draw() { cout << "Shape::draw() called" << endl; } }; class Circle : public Shape{ public: virtual void draw() { cout << "Circle::draw() called" << endl; } }; int main() { Shape *pShape = new Circle(); pShape->paint(); } */ /* #include<iostream> using namespace std; class Base{ public: virtual void f() { cout << "Base::f() called" << endl; } }; class Derived : public Base{ public: virtual void f() { cout << "Derived::f() called" << endl; } }; class GrandDerived : public Derived{ public: virtual void f() { cout << "GrandDerived::f() called" << endl; } }; int main() { GrandDerived g, *gp; Derived *dp; Base *bp; bp = dp = gp = &g; bp->Base::f(); dp->Derived::f(); gp->f(); } */ /* #include<iostream> using namespace std; class Shape{ public: virtual void draw() { cout << "--Shape--"; } }; class Circle : public Shape{ public: int x; virtual void draw() { Shape::draw(); cout << "Circle" << endl; } }; int main() { Circle circle; Shape *pShape = &circle; pShape->draw(); pShape->Shape::draw(); } */ /* #include<iostream> using namespace std; class Base{ public: virtual ~Base() { cout << "~Base()" << endl; } }; class Derived : public Base{ public: virtual ~Derived() { cout << "~Derived" << endl; } }; int main() { Derived *dp = new Derived(); Base *bp = new Derived(); delete dp; delete bp; } */ /* #include<iostream> using namespace std; class Calculator{ public: virtual int add(int a, int b) =0; virtual int subtract(int a, int b) =0; virtual double average(int a[], int size) =0; }; class GoodCalc : public Calculator{ public: virtual int add(int a, int b) { return a+b; } virtual int subtract(int a, int b) { return a-b; } virtual double average(int a[], int size) { double sum=0; for(int i=0;i<size;i++) { sum += a[i]; } return sum/size; } }; int main() { int a[] = {1,2,3,4,5}; Calculator *p = new GoodCalc(); cout << p->add(2,3) << endl; cout << p->subtract(2,3) << endl; cout << p->average(a,5) << endl; delete p; } */ /* #include<iostream> using namespace std; class Calculator{ void input() { cout << "정수 2 개를 입력하세요>>"; cin >> a >> b; } protected: int a,b; virtual int calc(int a, int b) =0; public: void run() { input(); cout << "계산된 값은 " << calc(a,b) << endl; } }; class Adder : public Calculator{ protected: virtual int calc(int a, int b) { return a+b; } }; class Subtractor : public Calculator{ protected: virtual int calc(int a, int b) { return a-b; } }; int main() { Adder adder; Subtractor subtractor; adder.run(); subtractor.run(); } */ #include<iostream> #include<string> using namespace std; class Converter{ protected: double ratio; virtual double convert(double src)=0; virtual string getSourceString()=0; virtual string getDestString()=0; public: Converter(double ratio) { this->ratio = ratio; } void run() { double src; cout << getSourceString() << "을" << getDestString() << "로 바꿉니다. "; cout << getSourceString() << "을 입력하세요."; cin >> src; cout << "변환결과 : " << convert(src) << getDestString() << endl; } }; class WonToDollar : public Converter{ protected: virtual double convert(double src) { return src/ratio; } virtual string getSourceString() { return "원"; } virtual string getDestString() { return "달러"; } public: WonToDollar(double ratio) { this->ratio = ratio; } }; int main() { WonToDollar wd(1010); wd.run(); }
0
0
3
taejun4612
2022년 8월 04일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> using namespace std; class Base{ public: void f() {cout << "Base::f() called" << endl;} }; class Derived : public Base{ public: void f() {cout << "Derived::f() called" << endl;} }; int main() { Derived d, *pDer; pDer = &d; pDer->f(); Base* pBase; pBase = pDer; pBase->f(); } */ /* #include<iostream> using namespace std; class Base{ public: virtual void f() { cout << "Base::f() called" << endl;} }; class Derived : public Base{ public: virtual void f() {cout << "Derived::f() called"<< endl;} }; int main() { Base *pBase; Derived d, *pDer; pBase = &d; pDer = (Derived*)pBase; pDer->f(); } */ /* #include<iostream> using namespace std; class Shape{ public: virtual void draw() { cout << "Shape" << endl; } }; class Circle : public Shape{ public: virtual void draw() { cout << "Circle" << endl; } }; class Rec : public Shape{ public: virtual void draw() { cout << "Rectangle" << endl; } }; class Line : public Shape{ public: virtual void draw() { cout << "Line" << endl; } }; void paint(Shape* p) { p->draw(); } int main() { paint(new Circle); paint(new Rec); paint(new Line); } */ /* #include<iostream> using namespace std; class Shape{ public: void paint() { draw(); } virtual void draw() { cout << "Shape::draw() called" << endl; } }; class Circle : public Shape{ public: virtual void draw() { cout << "Circle::draw() called" << endl; } }; int main() { Shape* pShape = new Circle; pShape->draw(); delete pShape; } */ /* #include<iostream> using namespace std; class Base{ public: virtual void f() { cout << "Base::f() called" << endl; } }; class Derived : public Base{ public: virtual void f() { cout << "Derived::f() called" << endl; } }; class GrandDerived : public Derived{ public: virtual void f() { cout << "GrandDerived::f() called" << endl; } }; int main() { GrandDerived g; Base *bp; Derived *dp; GrandDerived *gp; bp = dp = gp = &g; bp->f(); dp->f(); gp->f(); } */ /* #include<iostream> using namespace std; class Shape{ public: virtual void draw() { cout << "--Shape--"; } }; class Circle : public Shape{ public: virtual void draw() { Shape::draw(); cout << "Circle" << endl; } }; int main() { Circle circle; Shape *pShape = &circle; pShape->draw(); pShape->Shape::draw(); } */ /* #include<iostream> using namespace std; class Base{ public: virtual ~Base() { cout << "~Base" << endl; }; }; class Derived : public Base{ public: ~Derived() { cout << "~Derived" << endl; }; }; int main() { Base *p = new Derived(); delete p; } */ #include<iostream> using namespace std; class Shape{ Shape* next; protected: virtual void draw(); public: Shape() {next = NULL;} virtual ~Shape(){} void paint(); Shape* add(Shape* p); Shape* getNext() {return next;} }; void Shape::paint() { draw(); } void Shape::draw() { cout << "--Shape--" << endl; }
0
0
2
taejun4612
2022년 8월 02일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> #include<string> using namespace std; class Point{ int x, y; public: Point(int x, int y) {this->x = x; this-> y = y;} int getX() {return x;} int getY() {return y;} protected: void move(int x, int y) {this->x = x; this-> y = y;} }; class ColorPoint : public Point{ string color; public: ColorPoint(int x, int y, string color) : Point(x, y) { this-> color = color; } void setPoint(int x, int y) { move(x,y); } void setColor(string color) { this->color = color; } void show() { cout << color << "색으로 " << "(" << getX() << "," << getY() << ")" << "에 위치한 점입니다." << endl; } }; int main() { ColorPoint cp(5, 5, "RED"); cp.setPoint(10, 20); cp.setColor("BLUE"); cp.show(); } */ /* #include<iostream> #include<string> using namespace std; class Point{ int x,y; public: Point(int x, int y) {this->x = x; this->y = y;} int getX() {return x;} int getY() {return y;} protected: void move(int x, int y) {this->x = x; this->y = y;} }; class ColorPoint : Point{ string color; public: ColorPoint(int x=0, int y=0, string color="BLACK") : Point(x, y) { this->color = color; } void setPoint(int x, int y) { move(x, y); } void setColor(string color) { this->color = color; } void show() { cout << color << "색으로 " << "(" << getX() << "," << getY() << ")에 위치한 점입니다." << endl; } }; int main() { ColorPoint zeroPoint; zeroPoint.show(); ColorPoint cp(5, 5); cp.setPoint(10, 20); cp.setColor("BLUE"); cp.show(); } */ /* #include<iostream> using namespace std; class BaseArray{ private: int capacity; int *mem; protected: BaseArray(int capacity=100) { this->capacity = capacity; mem = new int [capacity]; } ~BaseArray() {delete [] mem;} void put(int index, int val) {mem[index] = val; } int get(int index) {return mem[index]; } int getCapacity() {return capacity; } }; class MyQueue : public BaseArray{ int x=-1,y=-1; public: MyQueue(int a) : BaseArray(a) {} void enqueue(int n) { y++; put(y,n); } int dequeue() { x++; return get(x); } int capacity() { return getCapacity(); } int length() { return y-x; } }; int main() { MyQueue mq(100); int n; cout << "큐에 삽입할 5개의 정수를 입력하라>> "; for(int i=0; i<5;i++) { cin >> n; mq.enqueue(n); } cout << "큐의 용량: " << mq.capacity() << ", 큐의 크기: " << mq.length() << endl; cout << "큐의 원소를 순서대로 제거하여 출력한다>> "; while(mq.length() != 0) { cout << mq.dequeue() << " "; } cout << endl << "큐의 현재크기: " << mq.length() << endl; } */ /* #include<iostream> using namespace std; class BaseArray{ private: int capacity; int *mem; protected: BaseArray(int capacity=100) { this->capacity = capacity; mem = new int [capacity]; } ~BaseArray() {delete [] mem;} void put(int index, int val) {mem[index] = val; } int get(int index) {return mem[index]; } int getCapacity() {return capacity; } }; class MyStack : public BaseArray{ int x=-1; public: MyStack(int a) : BaseArray(a) {} void push(int n) { x++; put(x, n); } int pop() { return get(x--); } int capacity() { return getCapacity(); } int length() { return x+1; } }; int main() { MyStack mstack(100); int n; cout << "스택에 삽입할 5개의 정수를 입력하라>> "; for(int i=0;i<5;i++) { cin >> n; mstack.push(n); } cout << "스택용량: " << mstack.capacity() << ", 스택크기: " << mstack.length() << endl; cout << "스택의 모든 원소를 팝하여 출력한다>> "; while(mstack.length() != 0) { cout << mstack.pop() << " "; } cout << endl << "스택의 현재크기: " << mstack.length() << endl; } */ /* #include<iostream> using namespace std; class BaseMemory{ char *mem; protected: BaseMemory(int size) {mem = new char[size]; } }; class ROM : public BaseMemory{ public: ROM(int memo, ) }; */ /* #include<iostream> using namespace std; class Base{ public: void f() { cout << "Base::f() called " << endl; } }; class Derived : public Base{ public: void f() {cout << "Derived::f() called" << endl; } }; int main() { Derived d, *pDer; pDer = &d; pDer->f(); Base* pBase; pBase = pDer; pBase->f(); } */ #include<iostream> using namespace std; class Base{ public: virtual void f() { cout << "Base::f() called" << endl;} }; class Derived : public Base{ public: virtual void f() {cout << "Derived::f() called" << endl;} }; int main() { Derived *pDer, d; pDer = &d; pDer->f(); Base* pBase; pBase = pDer; pBase ->f(); }
0
0
3
taejun4612
2022년 7월 28일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> #include<string> using namespace std; class TV{ int size; public: TV() {size = 20;} TV(int size) { this->size = size; } int getsize() { return size; } }; class WideTV : public TV{ bool videoIn; public: WideTV(int size, bool videoIn) : TV(size) { this->videoIn = videoIn; } bool getVideoIn() { return videoIn; } }; class SmartTv : public WideTV{ string ip; public: SmartTv(string ip, int size) : WideTV(size, true) { this->ip = ip; } string getip() { return ip; } }; int main() { SmartTv htv("192.0.0.1",32); cout << "size=" << htv.getsize() << endl; cout << "videoIn=" << boolalpha << htv.getVideoIn() << endl; cout << "ip=" << htv.getip() << endl; } */ /* #include<iostream> using namespace std; class Adder{ protected: int add(int a, int b) { return a+b; } }; class Subtractor{ protected: int minus(int a, int b) { return a-b; } }; class Calculator : public Adder, public Subtractor{ public: int calc(char op, int a, int b); }; int Calculator::calc(char op, int a, int b) { int res = 0; switch(op) { case '+' : res = add(a, b); break; case '-' : res = minus(a, b); break; } return res; } int main() { Calculator handCalculator; cout << "2 + 4 =" << handCalculator.calc('+', 2, 4) << endl; cout << "100 - 8 =" << handCalculator.calc('-', 100, 8) << endl; } */ /* #include<iostream> #include<string> using namespace std; class Circle{ int radius; public: Circle(int radius=0) {this->radius = radius;} int getRadius() {return radius;} void setRadius(int radius) {this->radius = radius;} double getArea() {return 3.14*radius*radius;} }; class NamedCircle : public Circle{ string name; public: NamedCircle(int radius, string name) { setRadius(radius); this-> name = name; } void show() { cout << "반지름이 " << getRadius() << "인 " << name << endl; } }; int main() { NamedCircle waffle(3, "waffle"); waffle.show(); } */ /* #include<iostream> #include<string> using namespace std; class Point{ int x,y; public: Point(int x, int y) { this->x = x; this->y = y;} int getX() {return x;} int getY() {return y;} protected: void move(int x, int y) {this-> x= x; this-> y = y;} }; class ColorPoint : public Point{ string color; public: ColorPoint(int x, int y, string color) : Point(x,y) { this-> color = color; } void setPoint(int x, int y) { move(x,y); } void setColor(string color) { this->color = color; } void show() { cout << color << "색으로 (" << getX() << "," << getY() << ")에 위치한 점입니다." << endl; } }; int main() { ColorPoint cp(5, 5, "Red"); cp.setPoint(10, 20); cp.setColor("Blue"); cp.show(); } */ #include<iostream> using namespace std; class BaseArray{ private: int capacity; int *mem; protected: BaseArray(int capacity=100) { this->capacity = capacity; mem = new int [capacity]; } ~BaseArray() {delete [] mem;} void put (int index, int val) {mem[index] = val;} int get(int index) {return mem[index];} int getCapacity() {return capacity;} }; class MyQueue : public BaseArray{ public: MyQueue(int capacity) : BaseArray(capacity) };
0
0
2
taejun4612
2022년 7월 26일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include <iostream> using namespace std; class data { private: int a, b, c; public: void setA(int x); int getA(); }; void data::setA(int x) { if(x < 1000) { return; } a = x; } int data::getA() { return a; } int main() { } */ /* #include<iostream> #include<string> using namespace std; class Point{ int x, y; public: void set(int x, int y) { this->x = x; this->y = y; } void showPoint() { cout << "(" << x << "," << y << ")" << endl; } }; class ColorPoint : public Point{ string color; public: void setColor(string color) { this->color = color; } void showColorpoint(); }; void ColorPoint::showColorpoint() { cout << color << ":"; showPoint(); } int main() { ColorPoint *pDer; Point *pBase, po; pBase = &po; pDer = (ColorPoint*)pBase; pDer->set(3,4); pDer->setColor("Red"); pDer->showColorpoint(); } */ /* #include<iostream> #include<string> using namespace std; class Point{ protected: int x, y; public: void set(int x, int y) { this->x = x; this->y =y; } void showPoint() { cout << "(" << x << "," << y << ")" << endl; } }; class ColorPoint : public Point{ string color; public: void setColor(string color) { this-> color = color; } void showColorpoint(); bool equals(ColorPoint p); }; void ColorPoint::showColorpoint() { cout << color << ":"; showPoint(); } bool ColorPoint::equals(ColorPoint p) { if(x==p.x&&y==p.y&&color==p.color) return true; else return false; } int main() { Point p; p.set(2,3); p.showPoint(); ColorPoint cp; cp.set(3,4); cp.setColor("Red"); ColorPoint cp2; cp2.set(3,4); cp2.setColor("Red"); cout << ((cp.equals(cp2))? "true" : "false"); } */ /* #include<iostream> using namespace std; class A{ public: A() {cout << "생성자 A" << endl;} A(int x){cout << "매개변수생성자 A" << x << endl;} }; class B : public A{ public: B(int t):A(t){cout << "생성자 B" << endl;} }; int main() { B b(3); } */ #include<iostream> #include<string> using namespace std; class TV{ int size; public: TV() {size = 20;} TV(int size) { this->size = size; } int getSize() { return size; } }; class WideTV : public TV{ bool videoIn; public: WideTV(int size, bool videoIn) : TV(size) { this->videoIn = videoIn; } bool getVideoIn() { return videoIn; } }; class SmartTV : public WideTV{ string ipAddr; public: SmartTV(string ipAddr, int size) : WideTV(size,true) { this->ipAddr = ipAddr; } string getIpAddr() { return ipAddr; } }; int main() { SmartTV htv("192.0.0.1",32); cout << htv.getSize() << endl; cout << boolalpha << htv.getVideoIn() << endl; cout << htv.getIpAddr() << endl; }
0
0
2
taejun4612
2022년 7월 21일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); Power& operator++(); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power& Power::operator++() { kick++; punch++; return *this; } int main() { Power a(3,5),b; a.show(); b.show(); b = ++a; a.show(); b.show(); } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); bool operator!(); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } bool Power::operator!() { if(kick == 0 && punch == 0) return true; else return false; } int main() { Power a(3,5),b(0,0); if(!a) cout << "a의 파워가 0이다." << endl; else cout<< "a의 파워가 0이 아니다." << endl; if(!b) cout << "b의 파워가 0이다." << endl; else cout << "b의 파워가 0이 아니다." << endl; } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); Power operator++(int x); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power Power::operator++(int x) { Power tmp = *this; kick++; punch++; return tmp; } int main() { Power a(3,5),b; a.show(); b.show(); b = a++; a.show(); b.show(); } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this-> punch = punch; } void show(); friend Power operator+(int op1, Power op2); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power operator+(int op1, Power op2) { Power tmp; tmp.kick = op1 + op2.kick; tmp.punch = op1 + op2.punch; return tmp; } int main() { Power a(3,5),b; a.show(); b.show(); b = 2 + a; a.show(); b.show(); } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); friend Power operator+(Power op1, Power op2); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power operator+(Power op1, Power op2) { Power tmp; tmp.kick = op1.kick + op2.kick; tmp.punch = op1.punch + op2. punch; return tmp; } int main() { Power a(3,5),b(4,6),c; a.show(); b.show(); c.show(); c = a + b; a.show(); b.show(); c.show(); } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); friend Power& operator++(Power op1); friend Power operator++(Power op1, int x); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power& operator++(Power& op1) { op1.kick++; op1.punch++; return op1; } Power operator++(Power& op1, int x) { Power tmp = op1; op1.kick++; op1.punch++; return tmp; } int main() { Power a(3,5),b; b = ++a; a.show(); b.show(); b = a++; a.show(); b.show(); } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); Power& operator<<(int n); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power& Power::operator<<(int n) { kick+=n; punch+=n; return *this; } int main() { Power a(1,2); a << 3 << 5 << 6; a.show(); } */ /* #include<iostream> #include<string> using namespace std; class Book{ string title; int price, pages; public: Book(string title="", int price=0, int pages=0) { this->title = title; this->price = price; this->pages = pages; } void show() { cout << title << ' ' << price << "원" << pages << "페이지" << endl; } string getTitle() { return title; } bool operator!(); }; bool Book::operator!() { if(price==0) return true; } int main() { Book } */ /* #include<iostream> using namespace std; class Color{ int red, green, blue; public: Color(int red=0, int green=0, int blue=0) { this->red = red; this->green = green; this->blue = blue; } void show(); Color operator+(Color op1); bool operator==(Color op1); }; void Color::show() { cout << red << " " << green << " " << blue << endl; } Color Color::operator+(Color op1) { Color tmp; tmp.red = this->red + op1.red; tmp.green = this->green + op1.green; tmp.blue = this->blue + op1.blue; return tmp; } bool Color::operator==(Color op1) { if(red==op1.red && green==op1.green && blue==op1.blue) return true; else return false; } int main() { Color red(255, 0, 0), blue(0, 0, 255), c; c = red + blue; c.show(); Color fuchsia(255, 0, 255); if(c == fuchsia) cout << "보라색 맞음"<< endl; else cout << "보라색 아님" << endl; } */ #include<iostream> using namespace std; class Matrix{ int a,b,c,d; public: Matrix(int a=0, int b=0, int c=0, int d=0) { this->a = a; this->b = b; this->c = c; this->d = d; } void show(); Matrix& operator>>(Matrix op1); Matrix& operator<<(Matrix op1); }; void Matrix::show() { cout << "Matrix = " << '{' << a << b << c << d << '}' << endl; } Matrix& Matrix operator>>(int op1[]) { op1.a = a; op1.b = b; op1.c = c; op1.d = d; return *this; } Matrix& Matrix::operator<<(int op1[]) { a = op1.a; b = op1.b; c = op1.c; d = op1.d; return *this; } int main() { Matrix a(4,3,2,1),b; int x[4], y[4] = {1,2,3,4}; a >> x; b << y; for(int i=0;i<4;i++) { cout << x[i] << ' '; } cout << endl; b.show(); }
0
0
2
taejun4612
2022년 7월 19일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); Power operator+ (Power op2); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power Power::operator+ (Power op2) { Power tmp; tmp.kick = this->kick + op2.kick; tmp.punch = this->punch + op2.punch; return tmp; } int main() { Power a(3,5), b(4,6), c; c= a + b; a.show(); b.show(); c.show(); } */ /* #include<iostream> using namespace std; class Rect; class RectManager{ public: bool equals(Rect r, Rect s); void copy(Rect& dest, Rect& src); }; class Rect{ int width, height; public: Rect(int width, int height) { this->width = width; this->height == height; } friend RectManager; }; bool RectManager::equals(Rect r, Rect s) { if(r.width==s.width&&r.height==s.height) return true; else return false; } void RectManager::copy(Rect& dest, Rect& src) { dest.width = src.width, dest.height = src.height; } int main() { Rect a(3,4), b(5,6); RectManager man; man.copy(b,a); if(man.equals(a,b)) cout << "equal" << endl; else cout << "not equal" << endl; } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); bool operator==(Power op2); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } bool Power::operator==(Power op2) { if(kick==op2.kick&&punch==op2.punch) return true; else return false; } int main() { Power a(3,5), b(3,5); a.show(); b.show(); if(a==b) cout << "equal" << endl; else cout << "not equal" << endl; } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); Power& operator+=(Power op2); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power& Power::operator+=(Power op2) { kick = kick + op2.kick; punch = punch + op2.punch; return *this; } int main() { Power a(3,5), b(4,6),c; a.show(); b.show(); c = a+=b; a.show(); c.show(); } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); Power operator+(int op2); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power Power::operator+(int op2) { Power tmp; tmp.kick = kick + op2; tmp.punch = punch + op2; return tmp; } int main() { Power a(3,5), b; a.show(); b.show(); b = a + 2; a.show(); b.show(); } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); Power& operator++(); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power& Power::operator++() { kick++; punch++; return *this; } int main() { Power a(3,4),b; a.show(); b.show(); b = ++a; a.show(); b.show(); } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); bool operator!(); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } bool Power::operator!() { if(kick==0&&punch==0) return true; else return false; } int main() { Power a(0,0), b(3,5); a.show(); b.show(); if(!a) cout << "a의 파워가 0이다." << endl; else cout << "a의 파워가 0이 아니다." << endl; if(!b) cout << "b의 파워가 0이다." << endl; else cout << "b의 파워가 0이 아니다." << endl; } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); Power operator++(int x); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power Power::operator++(int x) { Power tmp=*this; kick++; punch++; return tmp; } int main() { Power a(3,5),b; a.show(); b.show(); b = a++; a.show(); b.show(); } */ /* #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); friend Power operator+(int op1, Power op2); }; void Power::show() { cout << "kick=" << kick << ',' << "punch=" << punch << endl; } Power operator+(int op1, Power op2) { Power tmp; tmp.kick = op1+op2.kick; tmp.punch = op1+op2.punch; return tmp; } int main() { Power a(3,5),b; a.show(); b.show(); b = 2 + a; a.show(); b.show(); } */ #include<iostream> using namespace std; class Power{ int kick; int punch; public: Power(int kick=0, int punch=0) { this->kick = kick; this->punch = punch; } void show(); friend Power };
0
0
2
taejun4612
2022년 7월 12일
In 소스 코드 제출
/* #include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; } */ /* #include <iostream> using namespace std; class all { public: int a, b, c; void code() { cout << "A:LA" << endl; } }; class part : public all{ public: // int a, b, c; // overloading // part(); // part(int k); void show(); }; class part2 : public all { }; void part::show() { cout << "HELLOWORD" << endl; } int main() { part p; p.a = 10; p.show(); p.code(); } */ /* #include<iostream> #include<string> using namespace std; void star(int a=5); void msg(int id, string text=""); void star(int a) { for(int i=0; i<a; i++) { cout << "*"; } cout << endl; } void msg(int id, string text) { cout << id << ' ' << text << endl; } int main() { star(); star(10); msg(10); msg(10,"HELLO"); } */ /* #include<iostream> using namespace std; class Person{ public: int money; void addMoney(int money) { this->money += money; } static int sharedMoney; static void addShared(int n) { sharedMoney += n; } }; int Person::sharedMoney = 10; int main() { Person::addShared(50); cout << Person::sharedMoney << endl; Person han; han.money = 100; han.sharedMoney = 200; Person::sharedMoney = 300; Person::addShared(100); cout << han.money << ' ' << Person::sharedMoney << endl; } */ /* #include<iostream> using namespace std; class circle{ private: static int numofcircles; int radius; public: circle(int r=1); ~circle() { numofcircles--; } double getarea() { return 3.14*radius*radius; } static int getnumofcircles() { return numofcircles; } }; circle::circle(int r) { radius = r; numofcircles++; } int circle::numofcircles = 0; int main() { circle *p = new circle[10]; cout << circle::getnumofcircles() << endl; delete []p; cout << circle::getnumofcircles() << endl; circle a; cout << circle::getnumofcircles() << endl; circle b; cout << circle::getnumofcircles() << endl; } */ /* #include<iostream> using namespace std; int add(int arr[], int n) { int m=0; for(int i=0; i<n; i++) { m+=arr[i]; } return m; } int add(int arr[], int n, int arr1[]) { int v=0,z=0; for(int i=0;i<n;i++) { v+=arr[i]; } for(int i=0;i<n;i++) { z+=arr1[i]; } return z+v; } int main() { int a[] = {1, 2, 3, 4, 5}; int b[] = {6, 7, 8, 9, 10}; int c = add(a, 5); int d = add(a, 5, b); cout << c << endl; cout << d << endl; } */ /* #include<iostream> using namespace std; class num{ public: int big(int a, int b); int big(int a, int b, int c); }; int num::big(int a, int b) { if(a>b) { if(a<100) { return a; } else { return 100; } } else { if(b<100) { return b; } else { return 100; } } } int num::big(int a, int b, int c) { if(a>b) { if(a<c) { return a; } else { return c; } } else { if(b<c) { return b; } else { return c; } } } int main() { num t; int x = t.big(3, 5); int y = t.big (300, 60); int z = t.big (30, 60, 50); cout << x << ' ' << y << ' ' << z << endl; } */ /* #include<iostream> using namespace std; class ArrayUtility{ public: static void inttodouble(int source[], double dest[], int size); static void doubletoint(double source[], int dest[], int size); }; void ArrayUtility::inttodouble(int source[], double dest[], int size) { for(int i=0;i<size;i++) { dest[i] = source[i]; } } void ArrayUtility::doubletoint(double source[], int dest[], int size) { for(int i=0;i<size;i++) { dest[i] = source[i]; } } int main() { int x[] = {1, 2, 3, 4, 5}; double y[5]; double z[] = {9.9, 8.8, 7.7, 6.6, 5.6}; ArrayUtility::inttodouble(x, y, 5); for(int i=0;i<5;i++) { cout << y[i] << ' '; } cout << endl; ArrayUtility::doubletoint(z, x, 5); for(int i=0;i<5;i++) { cout << x[i] << ' '; } cout << endl; } */
0
0
5
taejun4612
2022년 7월 05일
In 소스 코드 제출
//#include <iostream> // //using namespace std; // //int main() //{ // int k; // cout << "Hello world!" << endl; // // cout << "he r" << " " << "asdasd" << endl; // // // for(int i=0; i<5; i++) { // int x = i*10; // cout << i*5 << " " << x << endl; // } // return 0; //} /* #include<iostream> using namespace std; int main() { int n, m; cin >> n >> m; cout << n+m << endl; } */ /* #include<iostream> using namespace std; int main() { int n; cin >> n; if(n%2==1) { cout << "oh my god" << endl; } else { cout << "enjoy" << endl; } return 0; } */ // //#include<iostream> // //using namespace std; // //int main() //{ // int n,m; // // cin >> n >> m; // // if(n%2) // { // cout << "熱+"; // } // else // // { // cout << "礎熱+"; // } //// cout << "+"; // if(m%2) // { // cout << "熱"; // } // else // { // cout << "礎熱"; // } // if((n+m)%2) // { // cout << "=熱" << endl; // } // else // { // cout << "=礎熱" << endl; // } // return 0; //} /* #include<iostream> using namespace std; int main() { int n; cin >> n; for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { cout << "(" << i << "," << j << ")" << "\t"; } cout << endl; } } */ /* #include<iostream> using namespace std; int main() { int n; cin >> n; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { cout << "*"; } cout << endl; } for(int i=1;i<=n-1;i++) { for(int j=1;j<=i;j++) { cout << "_"; } for(int k=n-1;k>=i;k--) { cout << "*"; } cout << endl; } return 0; } */ // //#include<iostream> // //using namespace std; // //int main() //{ // int n; // // cin >> n; // // for(int i=1;i<=n%2+1;i++) // { // for(int j=n%2;j>=i;j--) // { // cout << "_"; // } // for(int j=1;j<=i;j++) // { // cout << "*"; // } // cout << endl; // } //} /* #include<iostream> using namespace std; class part { public: part(); ~part(); int a, b, c; void show(); // proto type }; part::part() { // constructor a = 10; b = 20; c = 30; cout << "class started" << endl; } part::~part() { // destructor cout << "class ended" << endl; } void part::show() { int x; cout << "hello world" << endl; } int main() { part n; } */ /* #include<iostream> using namespace std; class circle{ public: int radius; double getarea(); }; double circle::getarea() { return 3.14*radius*radius; } int main() { circle donut; donut.radius=10; double area=donut.getarea(); cout << "donut 賊瞳擎" << area << endl; } */ /* #include<iostream> using namespace std; class part{ public: part(); void draw(int n); }; part::part() { } void part::draw(int n) { for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { cout << "*"; } cout << endl; } for(int i=1;i<=n-1;i++) { for(int j=1;j<=i;j++) { cout << "_"; } for(int k=n-1;k>=i;k--) { cout << "*"; } cout << endl; } } int main() { int n; cin >> n; part k; k.draw(n); } */ /* #include<iostream> using namespace std; class part{ public: part(); int a; int b; int getarea(); }; part::part(){ } int part::getarea(){ return a*b; } int main() { int n,m; cin >> n >> m; part k; k.a=n; k.b=m; cout << k.getarea() << endl; return 0; } */ /* #include<iostream> using namespace std; class part{ public: part(); int a; double getarea(); }; part::part() { } double part::getarea() { return 3.14*a*a; } int main() { int n; cin >> n; part k; k.a=n; cout << k.getarea() << endl; return 0; } */ /* #include <iostream> using namespace std; class sagwa{ public: sagwa(); sagwa(int k); sagwa(double k); }; sagwa::sagwa() { cout << "type 01" << endl; } sagwa::sagwa(int k) { cout << "type " << k << endl; } // overloading sagwa::sagwa(double k) { cout << "type zero" << endl; } int main() { sagwa x(100.5); } */ /* #include<iostream> using namespace std; class circle{ public: circle(); circle(int k); double getarea(); }; circle::circle() { int radius=1; } circle::circle(int k) { } int main() { circle donut; } */ // //#include<iostream> // //using namespace std; //class number{ //public: // number(); // int t,f; // void getnumber(int a); //}; //number::number() //{ // t=-1000000; // f=1000000; //} //void number::getnumber(int a) //{ // if(a>t) // { // t=a; // } // if(a<f) // { // f=a; // } //} //int main() //{ // int arr[5]={}; // number x; // for(int i=0;i<5;i++) // { // cin >> arr[i]; // x.getnumber(arr[i]); // } // cout << x.t << endl; // cout << x.f << endl; // // return 0; //} /* #include<iostream> using namespace std; int main() { int n; cin >> n; for(int i=1;i<=9;i++) { for(int j=1;j<=i*n;j++) { cout << "*"; } cout << endl; } return 0; } */ //#include <iostream> // //using namespace std; // //class teach { //public: // int max, min, inData[5] = {0}; // teach(); // teach(int data[]); // void find(); // void show(); //}; // //teach::teach() { // //} // //teach::teach(int data[]) { // for(int i=0; i<5; i++) { // inData[i] = data[i]; // } //} // //void teach::find() { // for(int i=0; i<5; i++) { // if() { // max = // } // if() { // min = // } // } //} // //void // //int main() { // // //} /* #include<iostream> using namespace std; class Tower{ public: Tower(); Tower(int a); int n; int getHeight(); }; Tower::Tower() { n=1; } Tower::Tower(int a) { n=a; } int Tower::getHeight() { return n; } int main() { Tower myTower; Tower seoulTower(100); cout << "높이는 " << myTower.getHeight() << "미터" << endl; cout << "높이는 " << seoulTower.getHeight() << "미터" << endl; } */ /* #include<iostream> using namespace std; class Random{ public: Random(); next(); nextInRange(int a, int b); }; Random::Random() { } int main() { } */ #include <iostream> using namespace std; void show(char v[]) { cout << "show: " << v << endl; } char* inShow() { char vv[100] = "WOWWOWOLRd"; return vv; } string inShow2() { return "asd"; } int main() { char word[100] = "HELL WORLD"; string word2 = "ASDASDASD"; cout << word2 << endl; cout << word << endl; show(word); cout << inShow() << endl; }
0
0
2
taejun4612
2022년 7월 02일
In 소스 코드 제출
//#include <stdio.h> // //int main(void) //{ // int n, i, j, x, y; // int array[20][20] = {0}; // // for(i = 1; i <= 19; i++) // { // for(j = 1; j <= 19; j++) // { // scanf("%d", &array[i][j]); // } // } // // scanf("%d", &n); // // for(i = 1; i <= n; i++) // { // scanf("%d %d", &x, &y); // for(j = 1; j <= 19; j++) // { // if(array[x][j] == 0) // { // array[x][j] = 1; // } // else { // array[x][j] = 0; // } // } // // for(j = 1; j <= 19; j++) // { // if(array[j][y] == 0) // { // array[j][y] = 1; // } // else { // array[j][y] = 0; // } // } // } // // for(i = 1; i <= 19; i++) // { // for(j = 1; j <= 19; j++) // { // printf("%d ", array[i][j]); // } // printf("\n"); // } // // return 0; //} //#include <stdio.h> // //int main(void) //{ // int n, d; // // scanf("%d", &n); // int k = n; // int i = 0, j = 0; // int arr[101][101] = {0}; // int c = 1; // int start = 0; // // // for(d = 1; d <= k*k; d++) // { // // if(j == start && i <= n) // { // if(i < n) // { // arr[i][j] = c++; // i++; // } // else { // arr[i][j] = c++; // } // } // // if(i == n - 1 && j <= n) // { // if(j < n) // { // arr[i][j] =c++; // j++; // } // else{ // arr[i][j]=c++; // } // } // // // if(j==n-1 && i>=start){ // if(i>start){ // arr[i][j]=c++; // i--; // } // else{ // arr[i][j]=c++; // } // } // // // // if(i==start && j>=start){ // if(j>start+1){ // arr[i][j]=c++; // j--; // } // else if(j==start+1){ // start++; // n--; // } // } // if(c>k*k) break; // // // } // // // for(j=0; j<k; j++){ // for(int i=0; i<k; i++){ // printf("%d ", arr[i][j]); // } // puts(""); // } // // return 0; //} #include <stdio.h> int main(void) { int m, n, x, y, i, j, k, l; scanf("%d %d %d %d", &m, &n, &x, &y); int array[101][101] = {0}; for(i = 1; i <= n; i++) { for(j = 1; j <= m; j++) { scanf("%d", &array[i][j]); } } int temp = 0; int sum = 0; for(i = 1; i <= n - y + 1; i++) { for(j = 1; j <= m - x + 1; j++) { for(k = 1; k <= y; k++) { for(l = 1; l <= x; l++) { sum += array[i + k][j + l]; } } if(sum > temp) { temp = sum; } sum = 0; } } printf("%d", temp); return 0; }
0
0
3
taejun4612
2022년 6월 30일
In 소스 코드 제출
//#include <iostream> // //using namespace std; // //int main() //{ // int k; // cout << "Hello world!" << endl; // // cout << "he r" << " " << "asdasd" << endl; // // // for(int i=0; i<5; i++) { // int x = i*10; // cout << i*5 << " " << x << endl; // } // return 0; //} /* #include<iostream> using namespace std; int main() { int n, m; cin >> n >> m; cout << n+m << endl; } */ /* #include<iostream> using namespace std; int main() { int n; cin >> n; if(n%2==1) { cout << "oh my god" << endl; } else { cout << "enjoy" << endl; } return 0; } */ // //#include<iostream> // //using namespace std; // //int main() //{ // int n,m; // // cin >> n >> m; // // if(n%2) // { // cout << "홀수+"; // } // else // // { // cout << "짝수+"; // } //// cout << "+"; // if(m%2) // { // cout << "홀수"; // } // else // { // cout << "짝수"; // } // if((n+m)%2) // { // cout << "=홀수" << endl; // } // else // { // cout << "=짝수" << endl; // } // return 0; //} /* #include<iostream> using namespace std; int main() { int n; cin >> n; for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { cout << "(" << i << "," << j << ")" << "\t"; } cout << endl; } } */ /* #include<iostream> using namespace std; int main() { int n; cin >> n; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { cout << "*"; } cout << endl; } for(int i=1;i<=n-1;i++) { for(int j=1;j<=i;j++) { cout << "_"; } for(int k=n-1;k>=i;k--) { cout << "*"; } cout << endl; } return 0; } */ // //#include<iostream> // //using namespace std; // //int main() //{ // int n; // // cin >> n; // // for(int i=1;i<=n%2+1;i++) // { // for(int j=n%2;j>=i;j--) // { // cout << "_"; // } // for(int j=1;j<=i;j++) // { // cout << "*"; // } // cout << endl; // } //} /* #include<iostream> using namespace std; class part { public: part(); ~part(); int a, b, c; void show(); // proto type }; part::part() { // constructor a = 10; b = 20; c = 30; cout << "class started" << endl; } part::~part() { // destructor cout << "class ended" << endl; } void part::show() { int x; cout << "hello world" << endl; } int main() { part n; } */ /* #include<iostream> using namespace std; class circle{ public: int radius; double getarea(); }; double circle::getarea() { return 3.14*radius*radius; } int main() { circle donut; donut.radius=10; double area=donut.getarea(); cout << "donut 면적은" << area << endl; } */ /* #include<iostream> using namespace std; class part{ public: part(); void draw(int n); }; part::part() { } void part::draw(int n) { for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { cout << "*"; } cout << endl; } for(int i=1;i<=n-1;i++) { for(int j=1;j<=i;j++) { cout << "_"; } for(int k=n-1;k>=i;k--) { cout << "*"; } cout << endl; } } int main() { int n; cin >> n; part k; k.draw(n); } */ /* #include<iostream> using namespace std; class part{ public: part(); int a; int b; int getarea(); }; part::part(){ } int part::getarea(){ return a*b; } int main() { int n,m; cin >> n >> m; part k; k.a=n; k.b=m; cout << k.getarea() << endl; return 0; } */ /* #include<iostream> using namespace std; class part{ public: part(); int a; double getarea(); }; part::part() { } double part::getarea() { return 3.14*a*a; } int main() { int n; cin >> n; part k; k.a=n; cout << k.getarea() << endl; return 0; } */ /* #include <iostream> using namespace std; class sagwa{ public: sagwa(); sagwa(int k); sagwa(double k); }; sagwa::sagwa() { cout << "type 01" << endl; } sagwa::sagwa(int k) { cout << "type " << k << endl; } // overloading sagwa::sagwa(double k) { cout << "type zero" << endl; } int main() { sagwa x(100.5); } */ #include<iostream> using namespace std; class circle{ public: circle(); circle(int k); double getarea(); }; circle::circle() { int radius=1; } circle::circle(int k) { } int main() { circle donut; }
0
0
1

taejun4612

더보기
bottom of page