top of page

게시판 게시물

노주희
2022년 1월 15일
In 소스 코드 제출
#6097 ''' h, w = map(int, input().split()) # w는 가로 h는 세로 n = input() # n은 막대의 개수 n = int(n) board = [[0]*w for i in range(h)] for i in range(n): l, d, x, y = map(int, input().split()) # l은 막대의 길이, d는 방향(가로: 0, 세로: 1) if d != 0: for j in range(l): board[x - 1+j][y - 1] = 1 else: for j in range(l): board[x-1][y-1+j] = 1 for i in range(h): for j in range(w): print(board[i][j], end=' ') print() ''' #6098 # # 0: 길, 1: 벽, 2: 먹이 # board = [[int(x) for x in input().split()]for y in range(10)] ''' house = [[0]*10 for _ in range(10)] for i in range(10): house[i] = list(map(int, input().split())) ''' # for in range() : # # class Maze: # # def __init__(self): # self.x=0 # self.y=0 # # # def func_c(self): # self.board = [[int(x) for 9 in input().split()]for y in range(9)] # return self.board # def func_b(self): # self.x =1 # self.y=1 # while True : # if self.board[self.x][self.y + 1] == 0: # self.board[self.x][self.y + 1] = 9 # return self.board # # elif self.board[self.x][self.y + 1] == 2: # self.board[self.x][self.y + 1]=9 # break # # elif self.board[self.x+1][self.y]==2: # self.board[self.x + 1][self.y]=9 # break # else: # self.board[self.x + 1][self.y] # return self.board # # m1= Maze(board) # print(m1.func_b()) class search: def __init__(self, map, x, y): self.map = map self.x = x self.y = y def process(self): ###### while True: if self.map[self.x][self.y] == 2: self.map[self.x][self.y] = 9 break else: if self.map[self.x][self.y + 1] == 0: self.map[self.x][self.y + 1] =0 self.map[self.x][self.y + 1] = 9 self.y=self.y + 1 elif self.map[self.x][self.y + 1] == 1: if self.x+1<<10: self.map[self.x + 1][self.y] = 9 self.x = self.x + 1 for i in range(len(self.map)): for j in range(len(self.map[i])): print(map[i][j], end=' ') print() map = [] for i in range(10): v = input().split() for j in range(len(v)): v[j] = int(v[j]) map.append(v) playing = search(map, 1, 1) playing.process() ''' #클래스 설명 class academy: def __init__(self): self.a = 100 print('HELLO') self.variable() def variable(self): self.a = 200 self.vv = 2000 print('WORLD') x = academy() x.variable() data = [] for i in range(5): p = academy() data.append(p) data[0].variable() '''
0
0
1
노주희
2022년 1월 05일
In 소스 코드 제출
#a = int(input()) ''' a, b = input().split(',') print(a +" " + b) ''' # a = (int)b # a = int(b) #6004 '''print("'Hello'")''' #6005 '''print('"Hello World"')''' #6006 '''print('\"!@#$%^&*()\'')''' #6008 '''print("print(\"Hello\\nWorld\")")''' #6016 '''a,b=input().split() print(b+" " +a)''' #6019 '''y, m, d =input().split('.') print(d+"-"+m+"-"+y)''' #6026 '''a=input() b=input() print(float(a)+float(b))''' #6030 '''n=ord(input()) print(n)''' #6033 '''n=ord(input()) print(chr(n+1))''' #6044 '''a,b=input().split() a=int(a) b = int(b) print(a+b) print(a-b) print(a*b) print(a//b) print(a%b) print(round(a/b,2))''' #6045 '''a,b,c=input().split() a=int(a) b=int(b) c=int(c) print('%d %.2f' %((a+b+c), (a+b+c)/3))''' #6048 '''a,b=input().split() a=int(a) b=int(b) print (a<b)''' #6056 '''a,b=input().split() c=bool(int(a)) d=bool(int(b)) print ((c and (not d)) or ((not c) and d))''' #6058 '''a,b=input().split() c=bool(int(a)) d=bool(int(b)) print((not c)and(not d))''' #6059 '''a=input() a=int(a) print((~a))''' #6062 '''a,b=input().split() a = int(a) b = int(b) print(a^b)''' #6064 '''a,b,c=input().split() a = int(a) b = int(b) c = int(c) print((a if a<b else b) if ((a if a<b else b)<c) else c)''' #6067 '''a=input() a=int(a) if a<0: if a%2==0: print('A') else : print('B') else: if a%2==0: print('C') else : print('D')''' #6069 '''a=input() if a=='A': print('best!!!') elif a=='B': print('good!!') elif a=='C': print('run!') elif a=='D': print('slowly~') else: print('what?')''' #6073 '''a=input() a=int(a) while a!=0: print(a) a=a-1''' #6073 '''a=input() a=int(a) while a!=0: print(a-1) a=a-1''' #6075 '''a=input() a=int(a) b=0 b=int(b) while b<=a: print(b) b=b+1''' ''' #리스트 설명 data = [] print(data) data.append(10) print(data) data.append(20) print(data) data.reverse() print(data) data.append(30) print(data) print(data[1]) data.sort() for i in range(len(data)): print(data[i]) ''' ''' #리스트 설명 data = [] for i in range(10): v = [0]*10 data.append(v) data[0][0] = 5 print(data) ''' ''' #튜플 설명 data = (10, 20, 30) print(data) data = list(data) data[0] = 50 data = tuple(data) print(data) ''' ''' # dictionary 설명 dic = {"apple":"johnmattang", "banana":"long"} # key : value print(dic.get("apple")) print(dic.keys()) ''' ''' #파이썬 그래프 import matplotlib.pyplot as plt import numpy as np xpoints = np.array([1, 8]) ypoints = np.array([3, -5]) plt.plot(xpoints, ypoints) plt.show() ''' ''' #클래스 설명 class fruit(): x = 10 y = 20 def __init__(self): self.x = 100 self.y = 200 print('Init Completed') self.allcow() def allcow(self): print('our all cows') x = fruit() ''' #6092 '''n = int(input()) a= input().split() for i in range(n): a[i]=int(a[i]) d=[] for i in range(24): d.append(0) for i in range(n): d[a[i]]+=1 for i in range(1, 24): print(d[i], end=' ')''' #6093 '''n = int(input()) k= input().split() for i in range(n): k[i]=int(k[i]) d=[] for i in range(23): d.append(0) for i in range(n-1, -1, -1) : print(k[i], end=' ')''' #6095 '''d=[] for i in range(20): d.append([]) for j in range(20): d[i].append(0) n=int(input()) for i in range(n): x,y = input().split() d[int(x)][int(y)]=1 for i in range(1, 20): for j in range(1, 20): print(d[i][j], end = ' ') print()'''
0
0
2
노주희
2021년 12월 09일
In 소스 코드 제출
#include <iostream> using namespace std; /* //419p NO.03 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(); ColorPoint(int x, int y, string s= " "): Point(x,y){ color=s; } void setPoint(int x, int y){ move(x,y); } void setColor(string s){ color=s; } void show() { cout << color << "색으로 ( " << getX() << "," << getY() << " )에 위치한 점입니다." << endl; } }; int main() { ColorPoint cp(5, 5, "RED"); cp.setPoint(10, 20); cp.setColor("BLUE"); cp.show(); } */ /* //419p NO.04 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() : Point(0, 0) { color = "BLACK"; } ColorPoint(int x, int y, string s = " ") : Point(x, y) { color = s; } void setPoint(int x, int y) { move(x, y); } void setColor(string s) { color = s; } 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(); } */ /* //421p NO.06 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 top; public: MyStack(int n):BaseArray(n){ top=0; } void push(int val){ put(top,val); top++; } int pop(){ top--; return get(top); } int capacity(){ return getCapacity(); } int length(){ return top; } }; 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; } */ /* //422p NO.08 class Printer { string model; string manu; int printed; int available; public: Printer() {} Printer(string model, string manu, int available) { this->model=model; this->manu=manu; this->available=available; } string getmodel() { return model; } string getmanu() { return manu; } void setprinted(int page) { printed=page; } int paper() { return available; } void print(int page) { available-=page; } }; class Inkjet: public Printer { public: int leftInk; Inkjet(string model, string manu, int printed, int leftInk) : Printer(model, manu, printed) { this->leftInk=leftInk; } printInk(int page) { setprinted(page); print(page); leftInk-=page; } void show() { cout<< "잉크젯 : " << getmodel() << ", " << getmanu() << ", 남은 종이 " << paper() << "장 , 남은 잉크 " << leftInk<< endl; } }; class Laser: public Printer { public: int toner; Laser(string model, string manu, int printed, int toner): Printer(model, manu, printed) { this->toner=toner; } void printlaser(int page) { setprinted(page); print(page); toner-=page/2; } void show() { cout << "레이저 : " << getmodel()<< ", " << getmanu() << ", 남은 종이" << paper()<< "장, 남은 토너" << toner<< endl; } }; int main() { Inkjet n("Officejet V40", "HP", 5, 10); Laser m("SCX-6x45", "삼성전자", 3, 20); cout<< "현재 작동중인 2대 프린터는 아래와 같다."<<endl; n.show(); m.show(); char a='y'; int b, c; while(a=='y') { cout << "프린터(1: 잉크젯, 2: 레이저)와 매수 입력>>"<< endl; cin >> b >> c ; switch(b) { case 1: if(n.paper()<c) { cout<< "용지가 부족하여 프린트할 수 없습니다."<< endl; break; } else if(n.leftInk<c) { cout<< "잉크가 부족하여 프린트할 수 없습니다."<< endl; break; } else { cout<< "프린트하였습니다."<<endl; n.printInk(c); break; } case 2: if(m.paper()<c) { cout<< "용지가 부족하여 프린트할 수 없습니다."<< endl; break; } else if(m.toner<c/2) { cout<< "토너가 부족하여 프린트할 수 없습니다."<< endl; break; } else { cout<< "프린트하였습니다."<<endl; m.printlaser(c); break; } } n.show(); m.show(); cout<< "계속 프린트 하시겠습니까(y/n)>> "; cin >> a; } } */
0
0
1
노주희
2021년 11월 03일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> #include <algorithm> using namespace std; /* //369p NO.07-1 class Matrix{ int ar[4]; public: Matrix() { for(int i=0; i<4; i++) ar[i] = 0; } Matrix(int a1, int a2, int b1, int b2) { ar[0] = a1; ar[1] = a2; ar[2] = b1; ar[3] = b2; } void show() {cout << "Matrix = { "; for(int i=0; i<4; i++) cout << ar[i] << ' '; cout << "}" << endl;} Matrix& operator >>(int n); Matrix& operator << (int n); } Matrix& Matrix::operator>>(int n){ for(int i=0; i<4; i++){ ar[i]==n[i] } } Matrix& Matrix::operator<<(){ for(int i=0; i<4; i++){ ar[i]==n[i] } } 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(); } */ /* //370p NO.10 class Statistics{ int* arr; int cnt; public: Statistics(){ arr= new int[100]; cnt=0;} bool operator!(){return(!arr);} Statistics& operator<<(int x){ arr[cnt]=x; cnt++; return* this; } void operator~(){ for(int i=0; i< cnt; i++){ cout<<arr[i]<<" "; } cout<<endl; } void operator>>(int& op2){2 op2=0; for(int i=0; i<cnt; i++){ op2+=arr[i]; } op2/=cnt; } }; int main(){ Statistics stat; if(!stat) cout << "현재 통계 데이타가 없습니다." << endl; int x[5]; cout<< "5 개의 정수를 입력하라>>"; for(int i=0; i<5; i++) cin >> x[i]; for(int i=0; i<5; i++) stat << x[i]; stat << 100 << 200; ~stat; int avg; stat >> avg; cout << "agv=" << avg << endl; } */ /* //371p NO.11 class Stack{ int* arr; int cnt; public: Stack(){arr= new int[100]; cnt=0;} ~Stack() {if(arr) delete[] arr;} Stack& operator<<(int op2){ arr[cnt]=op2; cnt++; return* this; } bool operator!(){ return(!arr[0]); } void operator>>(int& op2){ op2=arr[--cnt]; arr[cnt] = false; } }; int main(){ Stack Stack; Stack << 3 << 5 << 10; while(true){ if(!Stack) break; int x; Stack >> x; cout << x << ' '; } cout << endl; } */ /* //8장 상속 설명 class Parents{ public: int a, b, c; Parents() { cout<<"Parents Normal\n"; } Parents(int a, int b, int c) { cout << "Parents More\n"; } void show(); }; class Children : Parents{ public: Children() { cout << "child\n"; } int x, y, z; void run(); }; int main() { Parents p(10, 20, 30); cout << "-----------------\n"; Children c; // casting // up p = c; // down c = (Children)p; } */ /* //379p NO.8-1 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() { Point p; ColorPoint cp; cp.set(3,4); cp.setColor("Red"); cp.showColorPoint(); } */ /* //388p NO.8-2 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.x =5; p.y =5; p.showPoint(); ColorPoint cp; cp.x = 10; cp.y = 10; cp.set(3,4); cp.setColor("Red"); ColorPoint cp2; cp2.set(3,4); cp2.setColor("Red"); cout<<((cp.equals(cp2))?"true":"false"); } */ /* //395p NO.8-3 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 << "size="<< htv.getSize()<< endl; cout << "videoIn=" << boolalpha << htv.getVideoIn() << endl; cout << "IP=" << htv.getIpAddr()<<endl; } */ /* //399p NO.8-4 class Base{ int a; protected: void setA(int a) {this->a=a;} public: void showA() {cout << a;} }; class Derived : private Base{ int b; protected: void setB(int b) { this->b=b;} public: void showB(){cout<<b;} }; int main(){ Derived x; x.a=5; x.setA(10); x.showA(); x.b=10; x.setB(10); x.showB() ;} */ /* //400p NO.8-5 class Base{ int a; protected: void setA(int a){this->a=a;} public: void showA(){cout<< a; } }; class Derived : protected Base { int b; protected: void setB(int b) {this->b =b;} public: void showB() {cout << b;} }; int main(){ Derived x; x.a=5; x.setA(10); x.showA(); x.b=10; x.setB(10); x.showB(); } */ /* //401p NO.8-6 class Base{ int a; protected: void setA(int a){this->a=a;} public: void showA(){cout << a;} }; class Derived : private Base{ int b; protected: void setB(int b) {this->b=b;} public: void showB(){ setA(5); showA(); cout << b; } }; class GrandDerived : private Derived{ int c; protected: void setAB(int x){ setA(x); showA(); setB(x); } }; */ /* //404p NO.8-7 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; } */ /* //411p open challenge_다시 class Product{ protected: int id[100]; string }; int main(){ cout<< "***** 상품 관리 프로그램을 작동합니다 *****" << endl; for(;;){ cout<<"상품 추가(1), 모든 상품 조회(2), 끝내기(3) ?"; cin >>a; switch(a){ case '1': cout << "상품 종류 책(1), 음악CD(2), 회화팩(3) ?"; cin >> b; switch case '2': case '3': return 0; } } } */ /* //418p NO.01 class Circle{ public: int radius; Circle(int radius=0) {this->radius=radius; } int getRadius() {return radius;} void setRaius(int radius) {this->radius= radius;} double gerArea() {return 3.14*radius*radius;} }; class NamedCircle: public Circle{ string name; public: NamedCircle(int radius, string name); void show(); }; NamedCircle::NamedCircle(int radius, string name): Circle(radius) { this->name = name; } void NamedCircle::show(){ cout<< "반지름이 " <<getRadius() << "인 " << name<<endl; } int main() { NamedCircle waffle(3, "waffle"); waffle.show(); } */ //418p NO.2_다시 class Circle{ public: int radius; Circle(int radius=0) {this->radius=radius; } int getRadius() {return radius;} void setRaius(int radius) {this->radius= radius;} double gerArea() {return 3.14*radius*radius;} }; class NamedCircle: public Circle{ string name; public: NamedCircle(int radius, string name); void show(); }; NamedCircle::NamedCircle(int radius, string name): Circle(radius) { this->name = name; } void NamedCircle::show(){ cout<< "반지름이 " <<getRadius() << "인 " << name<<endl; } int main() { NamedCircle pizza[5]; cout<< "5 개의 정수 반지름과 원의 이름을 입력하세요"<<endl; for(i=0; i<5; i++){ cout << i << ">> "; cin >> } NamedCircle waffle(3, "waffle"); waffle.show(); }
0
0
4
노주희
2021년 10월 27일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> #include <algorithm> using namespace std; //367p NO.01-1 /* 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; } Book& operator +=(int price); Book& operator -=(int price); }; Book& Book::operator +=(int price) { this->price += price; return *this; } Book& Book::operator -=(int price) { this->price -= price; return *this; } int main() { Book a("청춘", 20000, 300), b("미래", 30000, 500); a += 500; b -= 500; a.show(); b.show(); } */ /* //367p NO.01-2 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; } friend Book& operator +=(Book& book,int price); friend Book& operator -=(Book& book ,int price); }; Book& operator +=(Book& book, int price) { book.price += price; return book; } Book& operator -=(Book& book, int price) { book.price -= price; return book; } int main() { Book a("청춘", 20000, 300), b("미래", 30000, 500); a += 500; b -= 500; a.show(); b.show(); } */ /* //367p NO.2-2 class Book{ public: string title; int price, pages; 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; } friend bool operator==(Book a, int b); friend bool operator==(Book a, string str); friend bool operator==(Book a, Book b); }; bool operator==(Book a, int b) { if (a.price == b) return true; else return false; } bool operator==(Book a, string str) { if (a.title == str) return true; else return false; } bool operator==(Book a, Book b) { if (a.price == b.price && a.title == b.title && a.pages == b.pages) return true; else return false; } int main(){ Book a("명품 C++", 30000, 500), b("고품 C++", 30000, 500); if(a == 30000) cout << "정가 30000원" << endl; if(a == "명품 C++") cout << "명품 C++입니다." << endl; if(a == b) cout << "두 책이 같은 책입니다." << endl; } */ /* //367p NO.03_다시 class Book{ public: string title; int price, pages; 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; } friend bool operator==(Book a, int b); }; bool operator==(Book a, int b) { if (a.price == 0) return true; else return false; } int main() { Book book("벼룩시장", 0, 50); if(!book) cout << "공짜다" << endl; } */ /* //367p NO.04 class Book{ int price, pages; public: string title; 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; } friend bool operator<( Book a, string str); }; bool operator<( Book a, string str) { if (a.title < str) return !true; else return !false; } int main(){ Book a("청춘", 20000, 300); string b; cout << "책 이름을 입력하세요>>"; getline(cin, b); if(a < b) cout << a.getTitle() << "이 " << b << "보다 뒤에 있구나!" << endl; } */ /* //368p NO.05-1 class Color{ public: int red, blue, green; Color(int red=0, int green=0, int blue=0){ this->red = red; this->green = green; this->blue=blue; } void show(){ cout << red << ' ' << green << ' ' << blue<< endl; } Color operator +(Color op2); bool operator==(Color op2); }; Color Color::operator +(Color op2){ Color tmp; tmp.red = this->red + op2.red; tmp.green = this->green + op2.green; tmp.blue = this->blue + op2.blue; return tmp; } bool Color::operator==(Color op2) { if (red == op2.red&&green==op2.green&&blue==op2.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 << "보라색 맞음"; else cout << "보라색 아님"; } */ /* //368p NO.06-2 class Matrix{ int ar[4]; public: Matrix() { for(int i=0; i<4; i++) ar[i] = 0; } Matrix(int a1, int a2, int b1, int b2) { ar[0] = a1; ar[1] = a2; ar[2] = b1; ar[3] = b2; } void show() {cout << "Matrix = { "; for(int i=0; i<4; i++) cout << ar[i] << ' '; cout << "}" << endl;} friend Matrix operator+(Matrix matrix1, Matrix matrix2); friend Matrix& operator+=(Matrix& matrix1, Matrix matrix2); friend bool operator==(Matrix matrix1, Matrix matrix2); }; Matrix operator+(Matrix matrix1, Matrix matrix2){ Matrix tmp; for(int i=0; i<4; i++) tmp.ar[i] = matrix1.ar[i] + matrix2.ar[i]; return tmp; } Matrix& operator+=(Matrix& matrix1, Matrix matrix2){ for(int i=0; i<4; i++) matrix1.ar[i] += matrix2.ar[i]; return matrix1; } bool operator==(Matrix matrix1, Matrix matrix2) { for(int i=0; i<4; i++) { if(matrix1.ar[i] != matrix2.ar[i]) return false; } return true; } int main() { Martix a(1,2,3,4), b(2,3,4,5), c; c = a + b; a +=b; a.show(); b.show(); c.show(); if(a == c) cout << "a and c are the same" << endl; } */ //369p NO.07-1_다시 class Matrix{ int ar[4]; public: Matrix() { for(int i=0; i<4; i++) ar[i] = 0; } Matrix(int a1, int a2, int b1, int b2) { ar[0] = a1; ar[1] = a2; ar[2] = b1; ar[3] = b2; } void show() {cout << "Matrix = { "; for(int i=0; i<4; i++) cout << ar[i] << ' '; cout << "}" << endl;} Matrix& operator >>(int n); Matrix& operator << (int n); } Matrix& Matrix::operator>>(int n){ for(int i=0; i<4; i++){ ar[i]==n[i] } } Matrix& Matrix::operator<<(){ for(int i=0; i<4; i++){ ar[i]==n[i] } } 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
5
노주희
2021년 10월 06일
In 소스 코드 제출
#include <iostream> #include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> #include <algorithm> using namespace std; /* //318p NO.09 class Board{ static string *text; static int num; public: static void add(string s){ text[num]= s; num++; } static void print(){ cout<< "********** 게시판입니다. **********"<<endl; for(int i=0; i<num; i++) cout<<i<< ":" << text[i]<<endl; } }; int Board::num=0; string *Board::text = new string[100]; int main() { Board::add("중간고사는 감독 없는 자율 시험입니다."); Board::add("코딩 라운지 많이 이용해 주세요."); Board::print(); Board::add("진소린 학생이 경진대회 입상하였습니다. 축하해주세요"); Board::print(); } */ /* //322p NO.7-1 class Rect; bool equals(Rect r, Rect s); class Rect{ int width, height; public: Rect(int width, int height){this->width = width; this -> height = height;} friend bool equals(Rect r, Rect s); }; bool equals(Rect r, Rect s) { if(r.width == s.width && r.height == s.height) return true; else return false; } int main() { Rect a(3,4), b(4,5); if(equals(a,b)) cout<< "equal" << endl; else cout << "not equal" << endl; } */ /* //324p NO.7-2 class Rect; class RectManager{ public: bool equals(Rect r, Rect s); }; class Rect{ int width, height; public: Rect(int width, int height) {this->width= width; this->height = height;} friend bool RectManager::equals(Rect r, Rect s); }; bool RectManager::equals(Rect r, Rect s) { if(r.width == s.width && r.height == s.height) return true; else return false; } int main() { Rect a(3,4), b(3,4); RectManager man; if(man.equals(a,b)) cout<< "equal"<<endl; else cout<< "not equal" << endl; } */ /* //325p NO.7-3 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; } */ /* //335p NO.7-4 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(); } */ /* //337p NO.7-5 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<< "두 파워가 같다." << endl; else cout<< "두 파워가 같지 않다."<< endl; } */ /* //339p NO.7-6 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(); } */ /* //341p NO.7-7 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(); } */ /* //344p NO.7-8 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(); } */ /* //345p NO.7-9 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(5,5); if(!a) cout<<"a의 파워가 0이다." <<endl; else cout << "a의 파워가 0이 아니다." << endl; if(!b) cout << "b의 파워가 0이다."<< endl; else cout<< "b의 파워가 0이 아니다."<<endl; } */ /* //347p NO.7-10 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(); } */ /* //351p NO.7-11 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(); } */ /* //353p NO.7-12 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; c=a+b; a.show(); b.show(); c.show(); } */ /* //355p NO.7-13 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& op); friend Power operator++(Power& op, int x); }; void Power::show(){ cout<< "kick= " << kick << ',' << "punch= " << punch<< endl; } Power& operator++(Power& op){ op.kick++; op.punch++; return op; } Power operator++(Power& op, int x){ Power tmp=op; op.kick++; op.punch++; return tmp; } int main(){ Power a(3,5), b; b=++a; a.show(); b.show(); b=a++; a.show(); b.show(); } */ /* //358p NO.7-14 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(); } */
0
0
4
노주희
2021년 9월 29일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> #include <algorithm> using namespace std; //316p NO.06 모르겠디 class ArrayUtility2{ public: static int* concat(int s1[], int s2[], int size); static int* remove(int s1[], int s2[], int size, int& retSize); }; int* ArrayUtility2::concat(int s1[], int s2[], int size){ int *a new int[size*2]; for(int i=0; i<size; ++i) a[i]=s1[i]; for(int i=0;i<size; ++i) a[1+size]=s2[i]; return a; } int* ArrayUtility2::remove(int s1[], int s2[], int size, int& retSize){ } int main(){ int x[5], y[5], *z; int retSize; cout << "정수를 5개 입력하라. 배열 x에 삽입한다>>"; for (int i = 0; i < 5; ++i) cin >> x[i]; cout << "정수를 5개 입력하라. 배열 y에 삽입한다>>"; for (int i = 0; i < 5; ++i) cin >> y[i]; z=ArrayUtility2::concat(x,y,5); cout<< "합친 정수 배열을 출력한다"<<endl; cout << z[i] << ' '; cout<< endl; z=ArrayUtility2::remove(x,y,5,retSize); cout<< "배열 x[]에서 y를 뺀 결과를 출력한다. 개수는 2"<<endl; for(int i=0; i<retSize; ++i) cout<<z[i]<< ' '; cout << endl; } */ /* //317p NO.08 class Trace{ static string tag[100]; static string debug[100]; static int size; public: static void put(string t, string d); static void print(string t); }; int Trace::size = 0; string Trace::tag[100]; string Trace::debug[100]; void Trace::put(string t, string d){ tag[size] =t; debug[size]=d; ++size; } void Trace:: print(string t = ""){ if(t== " "){ cout<< "-----모든 " } } void f(){ int a, b, c; cout << "두 개의 정수를 입력하세요>>"; cin >> a >> b; Trace::put("f()", "정수를 입력 받았음"); c= a+b; Trace::put("f()", "합 계산"); cout<< "합은 "<< c <<endl; } int main(){ Trace::put("main()", "프로그램 시작합니다."); f(); Trace::put("main()", "종료"); Trace::print("f()"); Trace::print(); } void Trace::print(string t = " ") { if (t == " ") { cout << "----- 모든 태그의 Trace 정보를 출력합니다. -----" << endl; for (int i = 0; i < size; ++i) cout << tag[i] << ":" << debug[i] << endl; } else { cout << "----- " << t << "태그의 Trace 정보를 출력합니다. -----" << endl; for (int i = 0; i < size; ++i) { if (tag[i] == "f()") cout << tag[i] << ":" << debug[i] << endl; } } } /* //318p NO.09 class Board{ public: void add }; int main() { Board::add("중간고사는 감독 없는 자율 시험입니다."); Board::add("코딩 라운지 많이 이용해 주세요."); Board::print(); Board::add("진소린 학생이 경진대회 입상하였습니다. 축하해주세요"); Board::print(); } */
0
0
2
노주희
2021년 9월 29일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> #include <algorithm> using namespace std; /* //313p NO.01-1 int add(int x[], int size) { int s = 0; for(int i=0; i<size; i++) s += x[i]; return s; } int add(int x[], int size, int y[]) { return add(x, size) + add(y, size); } 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; } */ /* //313p NO.02 class Person{ int id; double weight; string name; public: Person(); Person(int id, string name); Person(int id, string name, double weight); void show(){cout<<id<<' '<<weight<<' ' <<name<< endl;} }; Person::Person(){ this->id=1; this->name= "Grace"; this->weight=20.5; } Person::Person(int id, string name){ this->id=2; this->name="Ashley"; this->weight=20.5; } Person::Person(int id, string name, double weight){ this->id=3; this->name="Helen"; this->weight=32.5; } int main() { Person grace, ashley(2, "Ashley"), helen(3, "Helen", 32.5); grace.show(); ashley.show(); helen.show(); } */ /* //314p NO.03-1 int big(int a, int b){ int max =100; int x; x=(a>b)?a:b; return (x<max)? x:max; } int big(int a, int b, int max){ int x; x=(a>b)?a:b; return (x<max)?x:max; } int main() { int x = big(3, 5); int y = big(300, 60); int z = big(30, 60, 50); cout << x << ' ' << y << ' ' << z << endl; } */ /* //314p NO.04 class MyVector { int *mem; int size; public: MyVector(int n, int val); ~MyVector() { delete[]mem; } }; MyVector::MyVector(int n = 100, int val = 0) { mem = new int[n]; size = n; for (int i = 0; i < size; ++i) mem[i] = val; for (int i = 0; i < size; ++i) cout << mem[i] << ' '; cout << endl; cout << "size= " << size << endl; } int main() { MyVector a; MyVector b(5, 10); } */ /* //315p NO.05 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] =(double)source[i]; } void ArrayUtility::doubleToInt(double source[], int dest[], int size){ for(int i=0; i<size; i++) dest[i] = (int)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; } */ /* //316p NO.06 모르겠디 class ArrayUtility2{ public: static int* concat(int s1[], int s2[], int size); static int* remove(int s1[], int s2[], int size, int& retSize); }; int* ArrayUtility2::concat(int s1[], int s2[], int size){ int *a new int[size*2]; for(int i=0; i<size; ++i) a[i]=s1[i]; for(int i=0;i<size; ++i) a[1+size]=s2[i]; return a; } int* ArrayUtility2::remove(int s1[], int s2[], int size, int& retSize){ } int main(){ int x[5], y[5], *z; int retSize; cout << "정수를 5개 입력하라. 배열 x에 삽입한다>>"; for (int i = 0; i < 5; ++i) cin >> x[i]; cout << "정수를 5개 입력하라. 배열 y에 삽입한다>>"; for (int i = 0; i < 5; ++i) cin >> y[i]; z=ArrayUtility2::concat(x,y,5); cout<< "합친 정수 배열을 출력한다"<<endl; cout << z[i] << ' '; cout<< endl; z=ArrayUtility2::remove(x,y,5,retSize); cout<< "배열 x[]에서 y를 뺀 결과를 출력한다. 개수는 2"<<endl; for(int i=0; i<retSize; ++i) cout<<z[i]<< ' '; cout << endl; } */ /* //316p NO.07 class Random{ public: static void seed(){ srand((unsigned)time(0)); } static int nextInt(int min=0, int max=32767); static char nextAlphabet(); static double nextDouble(); }; int Random::nextInt(int min, int max){ int r= rand() % (max-min+1)+min; return r; } char Random::nextAlphabet(){ char c= rand() %2; if(c==0){ c=(rand()%26)+65; return c; } else{ c=(rand()%26)+97; return c; } } double Random::nextDouble(){ double d= rand()/ (double)(RAND_MAX+1);// 0부터 32767의 정수를 32768로 나누면 실수가 나온다 return d; } int main(){ Random::seed(); cout<<"1에서 100까지 랜덤한 정수 10개를 출력합니다."<<endl; for (int i = 0; i < 10; ++i) { cout << Random::nextInt(1, 100) << ' '; } cout<<endl; cout<<"알파벳을 랜덤하게 10개를 출력합니다."<<endl; for (int i = 0; i < 10; ++i) { cout << Random::nextAlphabet() << ' '; } cout<<endl; cout<< "랜덤한 실수를 10개 출력합니다."<<endl; for (int i = 0; i < 5; ++i) { cout << Random::nextDouble() << ' '; } cout << endl; for (int i = 0; i < 5; ++i) { cout << Random::nextDouble() << ' '; } cout << endl; } */
0
0
2
노주희
2021년 9월 15일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> #include <algorithm> using namespace std; /* //272P NO.08 class MyInStack{ int *p; int Size; int tos; public: MyInStack(); MyInStack(int Size); MyInStack(const MyInStack& s); ~MyInStack(); bool push(int n); bool pop(int &n); }; MyInStack::MyInStack(){ tos=0; cout << "Init St1"; } MyInStack::MyInStack(int Size){ this->Size=Size; tos = 0; p = new int[Size]; cout << "Init St2"; } MyInStack::MyInStack(const MyInStack& s){ this->p = s.p; this->Size = s.Size; this->tos = s.tos; } MyInStack::~MyInStack(){ } bool MyInStack::push(int n){ if(tos==10) return false; p[tos] =n; cout << "inand : " << n << endl; tos++; return true; } bool MyInStack::pop(int &n){ if(tos == 0) return false; tos--; n = p[tos]; return true; } int main() { MyInStack a(10); a.push(10); a.push(20); MyInStack b=a; b.push(30); cout<<1; int n; a.pop(n); cout<< "스텍 a에서 팝한 값 " << n<< endl; b.pop(n); cout<< "스텍 b에서 팝한 값" << n << endl; } */ /* //274P NO.10_ append 함수 다시 작성 class Buffer{ string text; public: Buffer(string text){this->text=text;} void add(string next) {text+=next;} void print(){cout<<text<<endl;} }; Buffer& append(Buffer& a,char *b){ a.add(b); return a; } int main() { Buffer buf("Hello"); Buffer& temp= append(buf, "Guys"); temp.print(); buf.print(); } */ /* //275P NO.12 class Dept{ int Size; int*scores; public: Dept(int Size){ this->Size=Size; scores= new int[Size]; } Dept(const Dept& dept); ~Dept(){delete[] scores;} int getSize() {return Size;} void read(); bool isOver60(int index); }; void Dept::read(){ int n, i; cout<<"10개의 점수 입력>> "; for( i=0; i<Size; i++){ cin>>n; scores[i]=n; } } Dept::Dept(const Dept& dept){ this->Size=dept.Size; this->scores=new int [this->Size]; for(int i=0; i<dept.Size; i++){ this->scores[i]=dept.scores[i]; } } bool Dept::isOver60(int index){ if(scores[index]>60) return true; else return false; } int countPass(Dept dept){ int Count=0; for(int i=0; i,dept.getSize(); i++){ if(dept.isOver60(i)) Count++; } return Count; } int main() { Dept com(10); com.read(); int n = countPass(com); cout<< "60점 이상은 "<< n<< "명"; } */ /* //280P 예제6-1 int big(int a, int b){ if(a>b) return a; else return b; } int big(int a[], int Size){ int res =a[0]; for(int i=1; i<Size; i++) if(res<a[i]) res=a[i]; return res; } int main(){ int array[5]={1, 9, -2, 8, 6}; cout<< big(2, 3)<<endl; cout<<big(array, 5)<< endl; } */ /* //281P 예제6-2 int sum(int a, int b){ int s=0; for(int i=a; i<=b; i++) s+=i; return s; } int sum(int a){ int s=0; for(int i=0; i<=a; i++) s+=i; return s; } int main(){ cout<<sum(3, 5) << endl; cout<<sum(3)<<endl; cout<<sum(100)<<endl; } */ /* //286P 예제6-3 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"); } */ /* //287P 예제6-4 void f(char c=' ', int line=1); void f(char c, int line){ for(int i=0; i<line; i++){ for(int j=0; j<10; j++) cout<<c; cout<<endl; } } int main(){ f(); f('%'); f('@', 5); } */ /* //289P 예제6-5 void fillLine(int n=25, char c='*'){ for(int i=0; i<n; i++) cout << c; cout<<endl; } int main(){ fillLine(); fillLine(10,'%'); } */ /* //290P 예제6-6 class MyVector{ int *p; int Size; public: MyVector(int n=100){ p= new int [n]; Size=n; } ~MyVector() {delete [] p;} }; int main(){ MyVector *v1,*v2; v1 = new MyVector(); v2 = new MyVector(1024); delete v1; delete v2; } */ /* //293P 예제6-7 float square(float a){ return a*a; } double square(double a){ return a*a; } int main(){ cout<<square(3.0); cout<<square(3); } */ /* //294P 예제6-8 int add(int a, int b){ return a+b; } int add(int a, int &b){ b=b+a; return b; } int main(){ int s=10, t=20; cout<< add(s,t); } */ /* //295P 예제6-9 void msg(int id){ cout<< id<< endl; } void msg(int id, string s=""){ cout<<id << ":"<<s<<endl; } int main(){ msg(5, "Good Morning"); msg(6); } */ /* //303P 예제6-10 class Math{ public: static int abs(int a) {return a>-0?a:-a;} static int max(int a, int b) {return (a>b)?a:b;} static int min(int a, int b) {return (a>b)?b:a;} }; int main(){ cout<< Math::abs(-5)<<endl; cout<< Math::max(10, 8) << endl; cout << Math::min(-3, -8)<< endl; } */ /* //304P 예제6-11 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; } */ /* //313p NO.01 int main(){ int a[]={1, 2, 3, 4, 5}; int b[]={6, 7, 8, 9, 10}; int c = add(a,5); int d = addd(a, 5, b); cout<< c<< endl; cout<<d<< endl; }*/ /* //313p NO.02 class Person{ int id; double weight; string name; public: Person(); Person(int id, string text=""); Person(int id, string text="", double weight); void show(){cout<<id<<' '<<weight<<' ' <<name<< endl;} }; Person::Person(){ } void grace(int 1, double 20.5, string "grace"); void ashley(double 20.5); int main() { Person grace, ashley(2, "Ashley"), helen(3, "Helen", 32.5); grace.show(); ashley.show(); helen.shoe(); } */
0
0
3
노주희
2021년 9월 08일
In 소스 코드 제출
6,8,10,12번 다시 해보기 #include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> #include <algorithm> using namespace std; /* //270P NO.02 void half(double &n){ n=n/2; } int main() { double n=20; half(n); cout<<n; } */ /* //270P NO.04 bool bigger(int a, int b, int& big){ if(a==b) return true; if(a>b) big=a; else big=b; return false; }; int main() { int x, y, big, b; cin>>x>>y; b=(x,y,big); if(b) cout<<"same"<<endl; else cout << "큰 수는"<< big << endl; } */ /* //270P NO.05 class Circle{ int radius; public: Circle(int r) {radius=r;} int getRadius() {return radius;} void setRadius(int r) { radius=r;} void show(){cout << "반지름이 " << radius<< "인 원"<<endl;} }; void increaseBy(Circle& a, Circle& b) { int r = a.getRadius() + b.getRadius(); a.setRadius(r); } int main(){ Circle x(10), y(5); increaseBy(x,y); x.show(); } */ /* //271P NO.06 //문자열과 문자 비교하는거 방법 char& Find(char a[], char c, bool& success){ if() return& true; else return& false; }; int main(){ char s[] = "Mike"; bool b= false; char& loc = Find(s, 'M', b); if(b==false){ cout << "M을 발견할 수 없다"<< endl; return 0; } loc='m'; cout <<s<<endl; } */ /* //272P NO.07 class MyInStack{ int p[10]; int tos; public : MyInStack(); bool push(int n); bool pop(int &n); }; MyInStack::MyInStack(){ tos=0; } bool MyInStack::push(int n){ if(tos==10) return false; p[tos] =n; tos++; return true; } bool MyInStack::pop(int &n){ if(tos == 0) return false; tos--; n = p[tos]; return true; } int main() { MyInStack a; for(int i=0; i<11; i++){ if(a.push(i)) cout<< i<< ' '; else cout<< endl << i+1 << " 번째 stack full" << endl; } int n; for(int i=0; i<11; i++){ if(a.pop(n)) cout<<n<<' '; else cout<< endl<< i+1<< " 번째 stack empty"; } cout<<endl; } */ /* //272P NO.08 class MyInStack{ int *p; int Size; int tos; public: MyInStack(); MyInStack(int Size); MyInStack(const MyInStack& s); ~MyInStack(); bool push(int n); bool pop(int &n); }; MyInStack::MyInStack(){ tos=0; } MyInStack::MyInStack(int Size){ tos=Size; } MyInStack::MyInStack(const MyInStack& s){ } MyInStack::~MyInStack(){ } bool MyInStack::push(int n){ if(tos==10) return false; p[tos] =n; tos++; return true; } bool MyInStack::pop(int &n){ if(tos == 0) return false; tos--; n = p[tos]; return true; } int main() { MyInStack a(10); a.push(10); a.push(20); MyInStack b=a; b.push(30); int n; a.pop(n); cout<< "스텍 a에서 팝한 값 " << n<< endl; b.pop(n); cout<< "스텍 b에서 팝한 값" << n << endl; } */ /* //273P NO.09 class Accumulator{ int value; public: Accumulator(int value); Accumulator& add(int n); int get(){return value;} }; Accumulator::Accumulator(int value){ this->value=value; } Accumulator& Accumulator:: add(int n){ value+=n; } int main(){ Accumulator acc(10); acc.add(5).add(6).add(7); cout<< acc.get(); } */ /* //274P NO.10_ append 함수 다시 작성 class Buffer{ string text; public: Buffer(string text){this->text=text;} void add(string next) {text+=next;} void print(){cout<<text<<endl;} }; char append(char& a[], char& b){ text= a[]+b; } int main() { Buffer buf("Hello"); Buffer& temp= append(buf, "Guys"); temp.print(); buf.print(); } */ /* //275P NO.12 class Dept{ int Size; int*scores; public: Dept(int Size){ this->Size=Size; scores= new int[Size]; } Dept(const Dept& dept); ~Dept(); int getSize() {return Size;} void read(); bool isOver60(int index); }; int countPass(Dept dept){ int Count=0; for(int i=0; i,dept.getSize(); i++){ if(dept.isOver60(i)) Count++; } return Count; } int main() { Dept com(10); com.read(); int n = countPass(com); cout<< "60점 이상은 "<< n<< "명"; } */
0
0
4
노주희
2021년 9월 02일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> #include <algorithm> using namespace std; /* //224P no.5-1 class Circle { private: int radius; public: Circle(); Circle(int r); ~Circle(); double getArea() { return 3.14*radius*radius; } int getRadius() { return radius; } void setRadius(int radius) { this->radius = radius; } }; Circle::Circle() { radius = 1; cout << "생성자 실행 radius = " << radius << endl; } Circle::Circle(int radius) { this->radius = radius; cout<< "생성자 실행 radius = " << radius << endl; } Circle::~Circle() { cout << "소멸자 실행 radius = " << radius << endl; } void increase(Circle c){ int r = c.getRadius(); c.setRadius(r+1); } int main() { Circle waffle(30); increase(waffle); cout<<waffle.getRadius() << endl; } */ /* //230P no.5-2 class Circle{ int radius; public: Circle() {radius=1;} Circle(int radius) {this->radius=radius;} void setRadius(int radius) {this->radius=radius;} double getArea() {return 3.14*radius*radius;} }; Circle getCircle(){ Circle tmp(30); return tmp; } int main() { Circle c; cout<<c.getArea()<<endl; c=getCircle(); cout<< c.getArea() << endl; } */ /* //234P no.5-3 int main() { cout << "i"<<'\t'<<"n"<<'\t'<<"refn" << endl; int i =1; int n =2; int &refn=n; n=4; refn++; cout<<i<<'\t'<<n<<'\t'<< refn<<endl; refn=i; refn++; cout<<i<<'\t'<<n<<'\t'<<refn<<endl; int*p=&refn; *p=20; cout<<i<<'\t'<<n<<'\t'<<refn<<endl; } */ /* //235P no.5-4 class Circle{ int radius; public: Circle(){radius=1;} Circle(int radius) {this->radius=radius;} void setRadius(int radius) {this->radius=radius;} double getArea(){return 3.14*radius*radius;} }; int main() { Circle circle; Circle &refc = circle; refc.setRadius(10); cout<<refc.getArea()<< " " << circle.getArea(); } */ /* //237P no.5-5 bool average(int a[], int Size, int& avg) { if(Size<=0) return false; int sum = 0; for(int i=0; i<Size; i++) sum += a[i]; avg = sum/Size; return true; } int main() { int x[] = {0,1,2,3,4,5}; int avg; if(average(x, 6, avg)) cout<< "평균은 " << avg << endl; else cout << "매개 변수 오류"<< endl; if(average(x, -2, avg)) cout<< "평균은 "<< avg<< endl; else cout << "매개 변수 오류 " << endl; } */ /* //239P no.5-6 class Circle{ private: int radius; public: Circle(); Circle(int r); ~Circle(); double getArea() {return 3.14*radius*radius;} int getRadius() {return radius;} void setRadius(int radius) {this->radius=radius;} }; Circle::Circle() { radius=1; cout << "생성자 실행 radius = "<< radius << endl; } Circle::Circle(int radius){ this->radius=radius; cout<< "생성자 실행 radius = " << radius << endl; } Circle::~Circle(){ cout<< "소멸자 실행 radius = " << radius << endl; } void increase(Circle &c){ int r=c.getRadius(); c.setRadius(r+1); } int main() { Circle waffle(30); increase(waffle); cout<< waffle.getRadius() <<endl; } */ /* //240P no.5-7 class Circle{ int radius; public: Circle() { radius =1; } Circle(int radius) {this->radius=radius;} void setRadius(int radius) {this->radius=radius;} double getArea() {return 3.14*radius*radius;} }; void readRadius(Circle &c){ int r; cout<< "정수 값으로 반지름을 입력하세요>>"; cin >> r; c.setRadius(r); } int main() { Circle donut; readRadius(donut); cout<< "donut의 면적 = " << donut.getArea() << endl; } */ /* //243P no.5-8 char& Find(char s[], int index) { return s[index]; } int main() { char name[] = "Mike"; cout<< name << endl; Find(name, 0) = 'S'; cout<< name<<endl; char& ref = Find(name, 2); ref = 't'; cout << name <<endl; } */ /* //249P no.5-9 class Circle{ private: int radius; public: Circle(const Circle& c); Circle() {radius=1;} Circle(int radius){this->radius=radius;} double getArea() {return 3.14*radius*radius;} }; Circle::Circle(const Circle& c){ this->radius=c.radius; cout<<"복사 생성자 실핼 radius = " << radius << endl; } int main(){ Circle src(30); Circle dest(src); cout<< "원본의 면적 = " << src.getArea() << endl; cout<< "사본의 면적 = " << dest.getArea() << endl; } */ /* //252P no.5-10 class Person{ char* name; int id; public: Person(int id, const char* name); ~Person(); void changeName(const char *name); void show() {cout<<id<<','<<name<<endl;} }; Person::Person(int id, const char* name){ this->id=id; int len=strlen(name); this->name=new char [len+1]; strcpy(this->name, name); } Person::~Person(){ if(name) delete [] name; } void Person::changeName(const char* name) { if(strlen(name) > strlen(this->name)) return; strcpy(this->name, name); } int main() { Person father(1, "Kitae"); Person daughter(father); cout << "daughter 객체 생성 직후 ----" << endl; father.show(); daughter.show(); daughter.changeName("Grace"); cout<<"daughter 이름을 Grace로 변경한 후 ----"<< endl; father.show(); daughter.show(); return 0; } */ /* //257P no.5-11 class Person{ char* name; int id; public: Person(int id, const char* name); Person(const Person& person); ~Person(); void changeName(const char *name); void show() {cout<< id << ','<< name<< endl;} }; Person::Person(int id, const char* name) { this->id=id; int len = strlen(name); this->name = new char [len+1]; strcpy(this->name, name); } Person::Person(const Person& person) { this->id = person.id; int len = strlen(person.name); this->name = new char [len+1]; strcpy(this->name, person.name); cout<<"복사 생성자 실행. 원본 객체의 이름"<< this->name<<endl; } Person::~Person(){ if(name) delete [] name; } void Person::changeName(const char* name){ if(strlen(name)>strlen(this->name)) return; strcpy(this->name, name); } int main() { Person father(1, "Kitae"); Person daughter(father); cout<<"daughter 객체 생성 직후 ----" << endl; father.show(); daughter.show(); daughter.changeName("Grace"); cout << "daughter 이름을 Grace로 변경한 후 ----"<< endl; father.show(); daughter.show(); return 0; } */ /* //263P no.5-12 void f(Person person){ person.changeName("dummy"); } Person g() { Person mother(2, "Jane"); return mother; } int main() { Person father(1, "Kitae"); Person son = father; f(father); g(); } */ /* //실습 문제 270P no.01 void swap(int &a, int &b){ int tmp; tmp = a; a=b; b=tmp; } int main(){ int m, n; cin>>m>>n; swap(m,n); cout<< m<< ' '<< n; } */
0
0
2
노주희
2021년 8월 14일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> #include <algorithm> using namespace std; /* //p.214 no.10 class Person{ string name; public: Person() { name=""; } Person(string name){ this->name = name;} string getName() { return name;} void setName(string name) { this->name = name; } }; class Family{ string name; Person *p; int Size; public: Family(string name, int Size); void setName(int index, string name); void show(); ~Family(); }; Family::Family(string name, int Size){ this->name = name; this->Size = Size; p = new Person [Size]; } Family::~Family(){ delete p; } void Family::setName(int index, string name) { p[index].setName(name); } void Family::show() { cout << name + " 가족은 다음과 같이 " << Size << "명 입니다." << endl; for(int i=0; i<Size; i++) { cout << p[i].getName() << '\t'; } cout << endl; } int main(){ Family *simpson = new Family("Simpson", 3); simpson->setName(0, "Mr. Simpson"); simpson->setName(1, "Mrs. Simpson"); simpson->setName(2, "Bart Simpson"); simpson->show(); delete simpson; } */ /* //p.215 no.11 class Container{ private: int Size; public: Container() {Size = 10;} void Fill() { Size = 10;} void consume() {Size--; } int getSize() { return Size; } }; class CoffeeVendingMachine{ Container tong[3]; void Fill(); void selectEspresso(); void selectAmericano(); void selectSugarCoffee(); void show(); public: void run(); }; void CoffeeVendingMachine::Fill(){ tong[0].Fill(); tong[1].Fill(); tong[2].Fill(); show(); } void CoffeeVendingMachine::selectEspresso(){ tong[0].consume(); tong[1].consume(); } void CoffeeVendingMachine::selectAmericano(){ tong[0].consume(); tong[1].consume(); tong[1].consume(); } void CoffeeVendingMachine::selectSugarCoffee(){ tong[0].consume(); tong[1].consume(); tong[1].consume(); tong[2].consume(); } void CoffeeVendingMachine::show(){ cout<< "커피 "<< tong[0].getSize() << ", "; cout<< "물 "<< tong[1].getSize()<< ", "; cout<< "설탕 "<< tong[2].getSize()<<endl; } void CoffeeVendingMachine::run(){ int n; cout << "***** 커피자판기를 작동합니다. *****" << endl; while(1){ if(tong[0].getSize()==0||tong[1].getSize()==0||tong[2].getSize()==0){ cout << "원료가 부족합니다." ; break; } else{ cout << "메뉴를 눌러주세요(1:에스프레소, 2:아메리카노, 3:설탕커피, 4:잔량보기, 5:채우기)>>"; cin >> n; if(n==1){ selectEspresso(); cout<< "에스프레소 드세요"<<endl; } else if(n==2){ selectAmericano(); cout<< "아메리카노 드세요"<<endl; } else if(n==3){ selectSugarCoffee(); cout<< "설탕커피 드세요"<<endl; } else if(n==4){show();} else if(n==5){Fill();} } } } int main(){ CoffeeVendingMachine v; v.run(); } */ /* //p.216 no.12 class Circle{ int radius; string name; public: void setCircle(string name, int radius); double getArea(); string getName(); }; class CircleManaer{ Circle *p; int Size; public: CircleManaer(); ~CircleManaer(); void searchByName(); void searchByArea(); }; CircleManaer::CircleManaer(int Size){ cin>>Size; circlearray[Size]; } void setCircle int main(){ } */ //p.217 no.13 class Histogram{ string text; int arr[26]; public: Histogram(); Histogram(string text); void put(string text); void putc(char c); void print(); ~Histogram(); }; Histogram::Histogram(){ } Histogram::Histogram(string text){ this->text=text; } void Histogram::put(string text){ this->text+=text; } void Histogram::putc(char c){ this->text+=c; } Histogram::~Histogram(){ } void Histogram::print(){ for(int i=0; i<26; i++) arr[i] = 0; cout << text << endl << endl; //소문자화 for(int k=0; k<text.length(); k++) { if(isalpha(text[k])) { char c = tolower(text[k]); arr[c - 'a']++; } } int alpha=0; for(int i=0; i<26; i++) alpha += arr[i]; cout << "총 알파벳 수 " << alpha << endl; cout << endl; for(int i=0; i<26; i++) { cout << char('a'+i) << " (" << arr[i] << ")" << " : "; for(int j=0; j<arr[i]; j++) cout << '*'; cout << endl;} } int main(){ Histogram elvisHisto("Wise men sat, only fools rush in But I can't help, "); elvisHisto.put("falling in love with you"); elvisHisto.putc('-'); elvisHisto.put("Elvis Presley"); elvisHisto.print(); }
0
0
2
노주희
2021년 8월 07일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> #include <algorithm> using namespace std; /* //p.212 no.05 int main() { int i=0; string s; srand((unsigned)time(0)); cout << "아래에 한 줄을 입력하세요.(exit를 입력하면 종료합니다)" << endl; while(true){ i++; cout<<">>"; getline(cin, s, '\n'); if(s=="exit") break; else{ int n= rand()%s.length(); s.replace(n, 1, "k"); cout<<s<<endl; } } } */ /* //p.212 no.06 //reverse 함수 사용 int main() { string s; int i=0; cout << "아래에 한 줄을 입력하세요.(exit를 입력하면 종료합니다)" << endl; while(true){ i++; cout<<">>"; getline(cin, s, '\n'); if(s=="exit") break; else{ reverse(s.begin(), s.end()); cout<< s << endl; } } } // 책에서 원한 풀이 int main() { string text; cout << "아래에 한 줄을 입력하세요.(exit를 입력하면 종료합니다)" << endl; while(true) { cout << ">>"; getline(cin, text, '\n'); if(text == "exit") break; int size = text.length(); int n = size/2; for(int i=0; i<n; i++) { char tmp = text[i]; text[i] = text[size-i-1]; text[size-i-1] = tmp; } cout << text << endl; } } */ /* //p.212 no.07 class Circle{ int radius; public: void setRadius(int radius); double getArea(); }; double Circle::getArea() { return 3.14*radius*radius; } void Circle::setRadius(int radius) { this->radius = radius; } int main() { int a=0; int radius; Circle circleArray[3]; for(int i=0; i<3; i++){ cout<<"원 "<< i+1 << "의 반지름 >>"; cin >> radius; circleArray[i].setRadius(radius); if( circleArray[i].getArea()>100) a+=1; } cout<<"면적이 100보다 큰 원은 "<< a << "개 입니다."; } */ /* //p.213 no.08 class Circle{ int radius; public: void setRadius(int radius); double getArea(); }; double Circle::getArea() { return 3.14*radius*radius; } void Circle::setRadius(int radius) { this->radius = radius; } int main() { int k; cout << "원의 개수 >>"; cin>> k; int a=0; int radius; Circle circleArray[k]; for(int i=0; i<k; i++){ cout<<"원 "<< i+1 << "의 반지름 >>"; cin >> radius; circleArray[i].setRadius(radius); if( circleArray[i].getArea()>100) a+=1; } cout<<"면적이 100보다 큰 원은 "<< a << "개 입니다."; } */ //p.213 no.09 class Person{ string name; string tel; public: Person(); string getName() {return name;} string getTel() {return tel; } void set(string name, string tel); }; Person::Person(){ } void Person::set(string name, string tel){ this->name= name; this->tel=tel; } int main(){ Person Infor[3]; string name, tel; cout<<"이름과 전화 번호를 입력해 주세요"<<endl; for(int i=0; i<3; i++){ cout<<"사람 " << i+1 <<">>"; getline(cin, name, ' '); name=Infor[i].getName(); getline(cin, tel, '\n'); tel=Infor[i].getTel(); } cout << "모든 사람의 이름은"; for(int i=0; i<3; i++){ cout<<Infor[i].getName()<< " "; } cout<< "\n" << "전화번호를 검색합니다. 이름을 입력하세요>>"; cout<<"전화번호는 "; } /* //p.214 no.10 class Person{ string name; public: Person(string name){ this->name = name;} string getName() { return name;} }; class Family{ Person *p; int size; public: Family(string name, int size); woid show(); ~Family(); }; int main(){ Family *simpson = new Family("Simpson", 3); simpson->setName(0, "Mr. Simpson"); simpson->setName(1, "Mrs. Simpson"); simpson->setName(2, "Bart Simpson"); simpson->show(); delete simpson; } */ p.213 no.9부터 다시 풀기
0
0
2
노주희
2021년 8월 01일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> using namespace std; /* //예제4-15 int main(){ string s; cout<< "여러 줄의 문자열을 입력하세요. 입력의 끝은 &문자입니다." << endl; getline(cin, s, '&'); cin.ignore(); string f, r; cout<< endl << "find: "; getline(cin, f, '\n'); cout << "replace: "; getline(cin, r, '\n'); int startIndex = 0; while(true){ int fIndex = s.find(f, startIndex); if(fIndex == -1) break; s.replace(fIndex, f.length(), r); startIndex = fIndex + r.length(); } cout<< s<< endl; } */ /* //p210 no.01 class Color{ int red, green, blue; public: Color() {red = green = blue = 0;} Color(int r, int g, int b) {red =r; green=g; blue=b;} void setColor(int r, int g, int b){red = r; green = g; blue = b; } void show() {cout << red << ' ' << green << ' ' << blue << endl;} }; int main(){ Color screenColor(225, 0, 0); Color *p; p = &screenColor; p->show(); Color colors[3]; p=colors; p[0].setColor(255, 0, 0); p[1].setColor(0, 255, 0); p[2].setColor(0, 0, 255); for(int i=0; i<3; i++) p[i].show(); } */ /* 클래스 사용할 것 //p211 no.02 class some{ int one, two, three, four, five, sum; public: input() {one = two = three = four = five = 0;} input(int o, int w, int h, int f, int v){one=o; two=w; three=h;four=f;five=v;} void reslut() }; some::reslut(){ } int main(){ cout<< "정수 5개 입력>>"; int *p = new input[5]; for(int i=0; i<5; i++){ cin>>p[i]; } double sum=0; for(int i=0; i<5; i++) sum+=p[i]; cout << "평균 "<< sum/5<<endl; delete [] p; } */ /* //no.02 클래스 없이 int main(){ cout<< "정수 5개 입력>>"; int *p = new int[5]; for(int i=0; i<5; i++){ cin>>p[i]; } double sum=0; for(int i=0; i<5; i++) sum+=p[i]; cout << "평균 "<< sum/5<<endl; delete [] p; } */ /* //p.211 no.03 int main() { string s; int sum=0; cout<< "문자열 입력>> "; getline(cin, s, '\n'); int length =s.length(); for(int i=0; i<length; i++) { int fIndex = s.find('a', i); cout<< fIndex<< " "; i=fIndex; sum+=1; } cout<< "문자 a는 " << sum << "개 있습니다."; } */ //p.211 no.04 class Sample { int *p; int Size; public: Sample(int n) { Size=n; p= new int [n]; } void read(); void write(); int big(); ~Sample(); }; void Sample::read() { for(int i=0; i<Size; i++) { cin>>p[i]; } } void Sample:: write() { for(int i=0; i<Size; i++) { cout<<p[i]<< " " ; } } Sample::~Sample() { delete p; } int Sample::big() { int v =p[0]; for(int i=0; i<Size; i++){ if(v<p[i]) v=p[i]; } return v; } int main() { Sample s(10); s.read(); s.write(); cout<< endl; cout << "가장 큰 수는 " << s.big() << endl; }
0
0
2
노주희
2021년 7월 24일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> using namespace std; //예제 4-1 /* class Circle{ int radius; public: Circle() {radius = 1;} Circle(int r) {radius = r; } double getArea(); }; double Circle::getArea(){ return 3.14*radius*radius; } int main(){ Circle donut; Circle pizza(30); cout << donut.getArea() << endl; Circle *p; p = &donut; cout << p->getArea() << endl; cout << (*p).getArea() << endl; p = &pizza; cout << p->getArea() << endl; cout << (*p).getArea() << endl; } */ //예제4-2 /* class Circle{ int radius; public: Circle() {radius = 1; } Circle(int r) { radius = r; } void setRadius(int r) { radius = r; } double getArea(); }; double Circle::getArea(){ return 3.14*radius*radius; } int main() { Circle circleArray[3]; circleArray[0].setRadius(10); circleArray[1].setRadius(20); circleArray[2].setRadius(30); for(int i=0; i<3; i++) cout << "Circle " << i << "의 면적은" << circleArray[i].getArea() << endl; Circle *p; p = circleArray; for(int i=0; i<3; i++){ cout << "Circle " << i << "의 면적은 "<< p->getArea() << endl; p++; } } */ //예제 4-3 /* class Circle{ int radius; public: Circle() {radius = 1;} Circle(int r) {radius = r;} void setRadius(int r){ radius = r; } double getArea(); }; double Circle::getArea() { return 3.14*radius*radius; } int main() { Circle circleArray[3] = { Circle(10), Circle(20), Circle()}; for(int i=0; i<3; i++) cout << "Circle " << i << "의 면적은 "<< circleArray[i].getArea() << endl; } */ //예제 4-4 /* class Circle{ int radius; public: Circle() { radius = 1;} Circle(int r) { radius = r; } void setRadius(int r) {radius = r; } double getArea(); }; double Circle::getArea() { return 3.14*radius*radius; } int main(){ Circle circle[2][3]; circle[0][0].setRadius(1); circle[0][1].setRadius(2); circle[0][2].setRadius(3); circle[1][0].setRadius(4); circle[1][1].setRadius(5); circle[1][2].setRadius(6); for(int i=0; i<2; i++) for(int j=0; j<3; j++) { cout << "Circle [" << i << "," << j << "]의 면적은 "; cout << circle[i][j].getArea() <<endl; } } */ //예제 4-5 /* int main() { int *p; p= new int; if(!p) { cout << "메모리를 할당할 수 없습니다. "; return 0; } *p = 5; int n = *p; cout << "*p = " << *p << endl; cout << "n = " << n << endl; delete p; } */ //예제 4-6 /* int main() { cout << "입력할 정수의 개수는?"; int n; cin>> n; if(n <=0) return 0; int *p = new int[n]; if(!p){ cout << "메모리를 할당할 수 없습니다."; return 0; } for(int i=0; i<n; i++) { cout << i+1 << "번째 정수: "; cin >> p[i]; } int sum = 0; for(int i=0; i<n; i++) sum += p[i]; cout << "평균 = " << sum/n << endl; delete [] p; } */ //예제 4-7 /* class Circle { int radius; public: Circle(); Circle(int r); ~Circle(); void setRadius(int r) { radius = r; } double getArea() {return 3.14*radius*radius; } }; Circle::Circle(){ radius = 1; cout << "생성자 실행 radius = " << radius << endl; } Circle::Circle(int r){ radius = r; cout << "생성자 실행 radius = " << radius << endl; } Circle::~Circle() { cout << "소멸자 실행 radius = " << radius << endl; } int main() { Circle *p, *q; p = new Circle; q = new Circle(30); cout << p->getArea() << endl << q->getArea() << endl; delete p; delete q; } */ //예제 4-8 /* class Circle{ int radius; public: Circle(); Circle(int r); ~Circle(); void setRadius(int r) { radius = r; } double getArea() { return 3.14*radius*radius; } }; Circle::Circle() { radius = 1; cout << "생성자 실행 radius = " << radius << endl; } Circle::Circle(int r){ radius = r; cout << "생성자 실행 radius = " << radius << endl; } Circle::~Circle(){ cout << "소멸자 실행 radius = " << radius << endl; } int main() { int radius; while(true){ cout << "정수 반지름을 입력(음수이면 종료)>> "; cin >> radius; if(radius < 0) break; Circle *p = new Circle(radius); cout << "원의 면적은 " << p->getArea() << endl; delete p; } } */ //예제 4-9 /* class Circle{ int radius; public: Circle(); Circle(int r); ~Circle(); void setRadius(int r) { radius = r; } double getArea() { return 3.14*radius*radius; } }; Circle::Circle(){ radius = 1; cout << "생성자 실행 radius = " << radius << endl; } Circle::Circle(int r){ radius =r; cout << "생성자 실행 radius = " << radius << endl; } Circle::~Circle(){ cout << "소멸자 실행 radius = " << radius << endl; } int main() { Circle *pArray = new Circle [3]; pArray[0].setRadius(10); pArray[1].setRadius(20); pArray[2].setRadius(30); for(int i=0; i<3; i++){ cout << pArray[i].getArea() << endl; } Circle *p = pArray; for(int i=0; i<3; i++){ cout << p->getArea() << endl; p++; } delete [] pArray; } */ //예제 4-10 /* class Circle{ int radius; public: Circle(); ~Circle() {} void setRadius(int r) { radius = r; } double getArea() { return 3.14*radius*radius; } }; Circle::Circle(){ radius = 1; } int main() { cout << "생성하고자 하는 원의 개수?"; int n, radius; cin >> n; if(n <= 0) return 0; Circle *pArray = new Circle [n]; for(int i=0; i<n; i++){ cout << "원" << i+1 << ": "; cin >> radius; pArray[i].setRadius(radius); } int count = 0; Circle* p = pArray; for(int i=0; i<n; i++){ cout << p->getArea() << ' '; if(p->getArea() >= 100 && p->getArea() <= 200) count++; p++; } cout << endl << "면적이 100에서 200 사이인 원의 개수는 " << count << endl; delete [] pArray; } */ //예제 4-11 /* int main() { string str; string address("서울시 성북구 삼선동 389"); string copyAddress(address); char text[] = {'L', 'O', 'V', 'E', ' ', 'C', '+', '+', '/0'}; string title(text); cout << str << endl; cout << address << endl; cout << copyAddress << endl; cout << title << endl; } */ //예제 4-12 /* int main() { string names[5]; for(int i=0; i<5; i++){ cout << "이름 >> "; getline(cin, names[i], '\n'); } string latter = names[0]; for(int i=1; i<5; i++){ if(latter < names[i]){ latter = names[i]; } } cout << "사전에서 가장 뒤에 나오는 문자열은 " << latter << endl; } */ //예제 4-13 /* int main() { string s; cout << "아래에 문자열을 입력하세요. 빈 칸이 있어도 됩니다. (한글 안됨)" << endl; getline(cin, s, '\n'); int len = s.length(); for(int i=0; i<len; i++){ string first = s.substr(0, 1); string sub = s.substr(1, len-1); s = sub + first; cout << s << endl; } } */ //예제 4-14 int main() { string s; cout << "7+23+5+100+25와 같이 덧셈 문자열을 입력하세요." << endl; getline(cin, s, '\n'); int sum =0; int startIndex = 0; while(true){ int fIndex = s.find('+', startIndex); if(fIndex == -1){ string part = s.substr(startIndex); if(part == "") break; cout << part << endl; sum += stoi(part); break; } int count = fIndex - startIndex; string part = s.substr(startIndex, count); cout << part << endl; sum += stoi(part); startIndex = fIndex+1; } cout << "숫자들의 합은 " << sum; }
0
0
3
노주희
2021년 7월 17일
In 소스 코드 제출
154p no.10 다시 풀 것 #include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <ctime> using namespace std; /* //150p.no.2 //independenceDay 출력이 문제 배열? class Date{ public: int x,y,z,n; Date(string v); Date(int year, int month, int day); int getYear(); int getMonth(); int getDay(); char show(); }; Date::Date(int year, int month, int day){ x=year, y=month, z=day; } int Date::getYear(){ return x; } int Date::getMonth(){ return y; } int Date::getDay(){ return z; } Date::Date(string v){ int n = stoi(v); } char Date::show(){ cout<<n<<endl; } int main() { Date birth(2014, 3, 20); Date independenceDay("1945/8/15"); independenceDay.show(); cout<< birth.getYear()<<','<<birth.getMonth()<<','<< birth.getDay()<<endl; } */ /* //150p no.03 class Account{ string name; int id; int balance; public: Account(string n, int i, int bal); void deposit(int money); int withdraw(int money); int inquiry(); string getOwner(){ return name; } }; Account::Account(string n, int i, int bal){ name=n; id=i; balance=bal; } void Account::deposit(int money){ balance+=money; } int Account::withdraw(int money){ balance-=money; } int Account::inquiry(){ return balance; } int main(){ Account a("kitae", 1, 5000); a.deposit(50000); cout<<a.getOwner()<<"의 잔액은 "<< a.inquiry()<<endl; int money = a.withdraw(20000); cout<< a.getOwner()<<"의 잔액은 "<< a.inquiry()<<endl; } */ /* //151p no.04 class CoffeeMachine{ int coffee; int water; int sugar; public: CoffeeMachine(int cof, int wat, int sug); void drinkEspresso(); void dirnkAmericano(); void drinkSugarCoffee(); void show(); void Fill(); }; CoffeeMachine::CoffeeMachine(int cof, int wat, int sug){ coffee=cof; water=wat; sugar=sug; } void CoffeeMachine::drinkEspresso(){ coffee-= 1; water-=1; } void CoffeeMachine::dirnkAmericano(){ coffee-=1; water-=2; } void CoffeeMachine::drinkSugarCoffee(){ coffee-=1; water-=2; sugar-=1; } void CoffeeMachine::show(){ cout<<"커피 머신 상태, 커피:"<< coffee<<" 물:"<<water<<" 설탕:"<<sugar<<endl; } void CoffeeMachine::Fill(){ coffee=10; water=10; sugar=10; } int main(){ CoffeeMachine java(5, 10, 3); java.drinkEspresso(); java.show(); java.dirnkAmericano(); java.show(); java.drinkSugarCoffee(); java.show(); java.Fill(); java.show(); } */ /* //151p no.05 class Random{ public: Random(); int next(); int nextInRange(int low, int high); }; Random::Random() { srand((unsigned)time(0)); } int Random::next() { return rand(); } int Random::nextInRange(int low, int high) { int range=(high-low)+1; return low + (rand() % range); } int main() { Random r; cout << "-- 0에서 " << RAND_MAX << "까지의 랜덤 정수 10 개--" << endl; for(int i=0; i<10; i++) { int n = r.next(); cout << n << ' '; } cout << endl << endl << "-- 2에서 " << "4 까지의 랜덤 정수 10 개 --" << endl; for(int i=0; i<10; i++) { int n = r.nextInRange(2, 4); cout << n << ' '; } cout << endl; } */ /* //152p no.06 class Random{ public: Random(); int next(); int nextInRange(int low, int high); }; Random::Random() { srand((unsigned)time(0)); } int Random::next() { return rand(); } int Random::nextInRange(int low, int high) { int range=(high-low)+1; return low + (rand() % range); } int main() { Random r; int i=0, k=0; cout << "-- 0에서 " << RAND_MAX << "까지의 랜덤 정수 10 개--" << endl; while(i < 10){ int n = r.next(); if (n%2==0){ i++; cout << n << ' '; } } cout << endl << endl << "-- 2에서 " << "4 까지의 랜덤 정수 10 개 --" << endl; while(k<10){ int n = r.nextInRange(2, 4); if (n%2==0){ k++; cout << n << ' '; } } cout << endl; } */ /* //153p no.08 class Integer{ public: int Integer; void get(); void Set(int some); void isEven(); }; int main(){ Integer n(30); cout<<n.get()<<''; n.Set(50); cout<< n.get()<<''; Integer m("300"); cout<<m.get<<''; cout << m.isEven(); } */ /* //153p no.09 class Oval{ int width; int height; public: Oval(); Oval(int w, int h); ~Oval(); int getWidth(); int getHeight(); void Set(int w, int h); void show(); }; Oval::Oval(){ width=height=1; } Oval::Oval(int w, int h){ width=w; height=h; } Oval::~Oval(){ cout<< "Oval 소멸 : "; show(); } int Oval::getWidth(){ return width; } int Oval::getHeight(){ return height; } void Oval:: Set(int w, int h){ width = w; height = h; } void Oval::show(){ cout << "width = " << width << ", " << "height = " << height << endl; } int main(){ Oval a, b(3, 4); a.Set(10, 20); a.show(); cout<< b.getWidth()<<","<<b.getHeight()<< endl; } */ /* //154p no.10 class Add{ }; class Sub{ }; class Mul{ }; class Div{ }; int main(){ cout<<"두 정수와 연산자를 입력하세요>>"; cin>>a>>b>>c; } */ /* //155p no.11 class Box{ int width, height; char Fill; public: Box(int w, int h){setSize(w,h); Fill='*';} void setFill(char f) {Fill=f;} void setSize(int w, int h) {width=w; height=h;} void draw(); }; void Box::draw(){ for(int n=0; n<height; n++){ for(int n=0; n<height; n++){ cout<<Fill; cout<<endl; } } } int main() { Box b(10, 2); b.draw(); cout<<endl; b.setSize(7, 4); b.setFill('^'); b.draw(); } */
0
0
6
노주희
2021년 7월 08일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> #include <string> using namespace std; /*//103p class Circle{ public: int radius; double getArea(); }; double Circle::getArea(){ return 3.14*radius*radius; } int main(){ Circle donut; donut.radius=1; double area = donut.getArea(); cout<<"donut 면적은 "<< area<< endl; Circle pizza; pizza.radius=30; area=pizza.getArea(); cout<<"pizza 면적은 "<<area<<endl; } */ /*//106p class Rectangle{ public: int width; int height; int getArea(); }; int Rectangle::getArea(){ return width*height; } int main(){ Rectangle rect; rect.width=3; rect.height=5; cout<<"사각형의 면적은 "<<rect.getArea()<<endl; } */ /*//110p class Circle{ public: int radius; Circle(); Circle(int r); double getArea(); }; Circle::Circle(){ radius=1; cout<<"반자름 "<<radius<<" 원 생성"<<endl; } Circle::Circle(int r){ radius=r; cout<<"반지름 "<<radius<<" 원 생성"<<endl; } double Circle::getArea(){ return 3.14*radius*radius; } int main(){ Circle donut; double area = donut.getArea(); cout<<"donut 면적은 "<< area<<endl; Circle pizza(30); area=pizza.getArea(); cout<<"pizza 면적은 "<< area<< endl; } */ /*//115p class Point{ int x,y; public: Point(); Point(int a, int b); void show() {cout<<"("<<x<<","<<y<<")"<<endl;} }; Point::Point() : Point(0,0){} Point::Point(int a, int b) :x(a), y(b) {} int main() { Point origin; Point target(10,20); origin.show(); target.show(); } */ /*//119p class Rectangle{ public: int width, height; Rectangle(); Rectangle(int w, int h); Rectangle(int lenght); bool isSquare(); }; Rectangle::Rectangle(){ width = height = 1; } Rectangle::Rectangle(int w, int h){ width = w; height = h; } Rectangle::Rectangle(int length){ width = height = length; } bool Rectangle::isSquare(){ if(width==height) return true; else return false; } int main() { Rectangle rect1; Rectangle rect2(3,5); Rectangle rect3(3); if(rect1.isSquare()) cout<< "rect1은 정사각형이다."<< endl; if(rect2.isSquare()) cout<< "rect2은 정사각형이다."<< endl; if(rect3.isSquare()) cout<< "rect3은 정사각형이다."<< endl; } */ /*//122p class Circle{ public: int radius; Circle(); Circle(int r); ~Circle(); double getArea(); }; Circle::Circle(){ radius=1; cout<<"반지름 "<<radius<<" 원 생성"<<endl; } Circle::Circle(int r){ radius=r; cout<<"반지름 "<<radius<<" 원 생성"<<endl; } Circle::~Circle(){ cout<<"반지름 "<< radius<<" 원 소멸"<<endl; } double Circle::getArea(){ return 3.14*radius*radius; } int main(){ Circle donut; Circle pizza(30); return 0; } */ /*//124p class Circle{ public: int radius; Circle(); Circle(int r); ~Circle(); double getArea(); }; Circle::Circle(){ radius=1; cout<<"반지름 "<<radius<<" 원 생성"<<endl; } Circle::Circle(int r){ radius=r; cout<<"반지름 "<<radius<<" 원 생성"<<endl; } Circle::~Circle(){ cout<<"반지름 "<<radius<<" 원 소멸"<<endl; } double Circle::getArea(){ return 3.14*radius*radius; } Circle globalDonut(1000); Circle globalPizza(2000); void f() { Circle fDonut(100); Circle fPizza(200); } int main() { Circle mainDonut; Circle mainpizza(30); f(); } */ /*//135p class StructCircle{ int radius; public: StructCircle(int r){ radius = r; } double getArea(); }; double StructCircle::getArea(){ return 3.14*radius*radius; } int main() { StructCircle waffle(3); cout<<"면적은 "<< waffle.getArea(); } */ /*//149p no.1 class Tower{ public: int h; Tower(); Tower(int r); int getHeight(); }; Tower::Tower(){ h=1; } Tower::Tower(int r){ h=r; } int Tower::getHeight(){ return h; } int main() { Tower myTower; cout<<"높이는 "<< myTower.getHeight()<<"미터"<<endl; Tower seoulTower(100); cout<<"높이는 "<< seoulTower.getHeight()<<"미터"<<endl; } */ //independenceDay 출력이 문제 배열? class Date{ public: int x,y,z,n; Date(string v); Date(int year, int month, int day); int getYear(); int getMonth(); int getDay(); char show(); }; Date::Date(int year, int month, int day){ x=year, y=month, z=day; } int Date::getYear(){ return x; } int Date::getMonth(){ return y; } int Date::getDay(){ return z; } Date::Date(string v){ int n = stoi(v); } char Date::show(){ cout<<n<<endl; } int main() { Date birth(2014, 3, 20); Date independenceDay("1945/8/15"); independenceDay.show(); cout<< birth.getYear()<<','<<birth.getMonth()<<','<< birth.getDay()<<endl; }
0
0
3
노주희
2021년 7월 01일
In 소스 코드 제출
#include <iostream> #include <cstring> #include <cstdlib> #include <cctype> #include <cstring> using namespace std; /* //90p no.8 cout<<"5명의 이름을 ';'으로 구분하여 입력하세요"<<endl; cout<<"<<"; char name[100]; cin.getline(name, 100, ';'); } */ /* //91p no.10 int main() { cout << "문자열을 입력>>"; char some[100]; cin.getline(some, 100, '\n'); for(int i=0; i<strlen(some); i++) { for(int k=0; k<=i; k++) { cout << some[k]; } cout<<endl; } } */ /* //91p no.11 int main() { int n=0; int sum=0; cout << "끝 수를 입력하세요>>"; cin >> n; for(int k=1; k<=n; k++) { sum+=k; } cout << "1에서 "<< n <<"까지의 합은 "<<sum<<"입니다."; } */ /* //92p no.12 int sum(int a, int b); int main() { int n=0; int j=0; cout<<"끝 수를 입력하세요>>"; cin >> n; cout<<"1에서 "<< n <<"까지의 합은 "<<sum(1,n)<<"입니다."; return 0; } int sum(int a, int b) { int res=0; for(int k=a; k<=b; k++) { res+=k; } return res; } */ /* //92p no.13 int main() { int a, b; cout<<"***** 승리장에 오신 것을 환영합니다. *****"<<endl; for(;;) { cout<<"짬뽕:1, 짜장:2, 군만두:3, 종료:4>>"; cin>>b; switch(b) { case 1: cout<<"몇인분?"; cin>>a; break; case 2: cout<<"몇인분?"; cin>>a; break; case 3: cout<<"몇인분?"; cin>>a; break; case 4: cout<<"오늘 영업은 끝났습니다."<<endl; return 0; default: cout<<"다시 주문하세요!!"<<endl; break; } } } */ /* //93p no.14 int main() { cout<<"에스프레소 2000원, 아메리카노 2300원, 카푸치노 2500원입니다."<<endl; char coffee[100]; int num, total, sum=0; for(;;) { cout<<"주문>> "; cin>>coffee>>num; if(sum>=20000) { cout<<"오늘 "<<sum<<"원을 판매하여 카페를 닫습니다. 내일 봐요~~~"; return 0; } else if(strcmp(coffee, "에스프레소")==0) { total= 2000*num; sum+=2000*num; cout<< total<<"원입니다. 맛있게 드세요."<<endl; } else if(strcmp(coffee, "아메리카노")==0) { total= 2300*num; sum+=2300*num; cout<< total<<"원입니다. 맛있게 드세요."<<endl; } else if(strcmp(coffee, "카푸치노")==0) { total= 2500*num; sum+=2500*num; cout<< total<<"원입니다. 맛있게 드세요."<<endl; } } } */ /* //93p no.15 int main() { int a, c, d=0; char b; for(;;) { cout<<"? "; cin>>a>>b>>c; switch(b) { case'+': d=a+c; cout<<a<<b<<c<<"="<<d<<endl; break; case'-': d=a-c cout<<a<<b<<c<<"="<<d<<endl; break; case'*': d=a*c; cout<<a<<b<<c<<"="<<d<<endl; break; case'/': d=a/c; cout<<a<<b<<c<<"="<<d<<endl; break; case'%': d=a%c; cout<<a<<b<<c<<"="<<d<<endl; break; } } } */ /* //94p no.16 int main() { cout<<"영문 텍스트를 입력하세요. 히스토그램을 스립니다."<<endl; cout<<"텍스트의 끝은 ; 입니다. 10000개까지 가능합니다."<<endl; int alpha=0; int arr[26]={0}; char some[10000]={0}; cin.getline(some, 10000, ';'); for(int i=0; i<10000; i++) { if(isalpha(some[i])==1||isalpha(some[i])==2) alpha+=1; } cout<<"총 알파벳 수 "<<alpha<<endl<<endl; for(int k=0; k<10000; k++) { if('A'<=some[k]&&some[k]<='Z'){ some[k]=tolower(some[k]); } if('a'<=some[k]&&some[k]<='z'){ arr[some[k]-'a']++; } } for(int j=0; j<26; j++) { cout<<(char)(j+'a')<<" ("<<arr[j]<<") : "; for(int t=0; t<arr[j]; t++){ cout<<"*"; } cout<<endl; } } */ /* Wise men say, only fools rush in But I can't help, falling in love with you Shall I stay? Would it be a sin? If I can't help, falling in love with you Like a river flows, surely to the sea, Darling so it goes, some things aren't meant to be */
0
0
5
노주희
2021년 6월 24일
In 소스 코드 제출
C++ 51p~52p / 88p~91p /* #include <iostream> using namespace std; int main() { int a, b, c; int k; cin >> k; int map[k][k] = {0}; for(int i=0; i<5; i++) { for(int j=0; j<5; j++) { cout << map[i][j] << ' '; } cout << endl; } cin >> a >> b >> c; cout << a+b << endl; cout << b << "+" << c << endl; cout << c << endl; for(int i=0; i<5; i++) { cout << i << ' '; } return 0; } */ /* #include <iostream> using namespace std; class party { public: int a, b, c; void show(); int calcu(); // contructor party(); // destructor ~party(); }; void party::show() { cout << "Let's PARTY!!!!"; } party::party() { a = 10; b = 20; c = 30; cout << "PARTY START!!!\n"; } party::~party() { cout << "PARTY END\n"; } int main() { { party p; p.show(); cout << p.a; } cout << "-----------\n"; } */ #include <iostream> #include <cstring> using namespace std; /* //51p~52p //No.1 int main(){ cout<<"My name is Mike.\n"; return 0; } */ /* //No.2 int main() { cout<<"전자공학과"<<endl; cout<<"21세"<<endl; cout<<"회사원"<<endl; return 0; } */ /* //No.3 int main () { cout<<"1에서 10까지 더한 "; cout<<"결과는"<<55<<"입니다"; } */ /* //No.4 int main() { cout<<"*"<<endl; cout<<"**"<<endl; cout<<"***"<<endl; cout<<"****"<<endl; } */ /* //88p~94p //No.1 int main() { for(int i=1; i<101; i++) { cout<<i<<" "; if(i%10==0) cout<<"\n"; } } */ /* //No.2 int main() { int some[i][j]={0}; for() } */ /* //No.3 int main() { int a, b, c=0; cout<<"두 수를 입력하라>>"; cin >> a >> b; if(a>b) c=a; else if(b>a) c=b; cout << "큰 수 = " << c; } */ /* //No.4 int main() { double some[5]={0} , ma=0; cout << "5 개의 실수를 입력하라>>"; for(int i=0; i<5; i++) { cin >> some[i]; if (some[i]>ma) ma=some[i]; } cout << ma; } */ /* //No.5 int main() { int a=0; char some[100]; cout << "문자들을 입력하라(100개 미만).\n"; cin.getline(some, 100, '\n'); for(int i=0; i<100 ; i++) { if(some[i]=='x') a+=1; } cout << "x의 개수는 " << a; } */ /* //No.6 int main() { int a=0; char fir[100]={0}, sec[100]={0}; cout << "새 암호를 입력하세요>>"; cin.getline(fir, 100, '\n'); cout << "새 암호를 다시 한 번 입력하세요>>"; cin.getline(sec, 100, '\n'); for(int i=0; i<100; i++) { if (fir[i]!=sec[i]) a+=1; } if(a==0) cout << "같습니다"; else cout << "같지 않습니다"; } */ /* //No.7 int main() { int i=0; char input[100]={0}; while(i<100){ cout << "종료하고싶으면 yes를 입력하세요>>"; cin.getline(input, 100, '\n'); i++; if(strcmp(input, "yes") ==0) { cout << "종료합니다..." << endl; break; } else; } } */ /* //No.8 int main() { char name[100]; for(int i=0; i<5; i++) { cin.getline(name,100, ';'); } } */ /* //No.9 int main() { char name[100]={0}, address[100]={0}, age[100]={0}; cout << "이름은?"; cin.getline(name, 100, '\n'); cout << "주소는?"; cin.getline(address, 100, '\n'); cout << "나이는?"; cin.getline(age, 100, '\n'); cout << name << ", " << address << ", " << age << "세"; } */ //No.10 int main() { char input[100]={0}; cout << "문자열 입력>>"; cin.getline(input, 100, '\n'); for(int i=0; i<100; i++) { } }
0
0
5
노주희
2021년 6월 24일
In 소스 코드 제출
#include <stdio.h> #include <stdlib.h> //1460 /* int main() { int map[100][100] = {0}; int i, j, n, k=1; scanf("%d", &n); for(i=0; i<n; i++) { for(j=0; j<n; j++) { map[i][j] = k++; } } for(i=0; i<n; i++) { for(j=0; j<n; j++) { printf("%d ", map[i][j]); } printf("\n"); } } */ //1462 /* int main() { int map[100][100] = {0}; int i, j, n, k=1; scanf("%d", &n); for(i=0; i<n; i++) { for(j=0; j<n; j++) { map[j][i] = k++; } } for(i=0; i<n; i++) { for(j=0; j<n; j++) { printf("%d ", map[i][j]); } printf("\n"); } } */ //1464 /* int main() { int map[100][100] = {0}; int i, j, n, m, k=1; scanf("%d", &n); scanf("%d", &m); for(i=0; i<n; i++) { for(j=0; j<m; j++) { map[i][j] = k++; } } for(i=n-1; i>-1; i--) { for(j=m-1; j>-1; j--) { printf("%d ", map[i][j]); } printf("\n"); } } */ //1465 /* int main() { int map[100][100] = {0}; int i, j, n, m, k=1; scanf("%d", &n); scanf("%d", &m); for(i=0; i<n; i++) { for(j=0; j<m; j++) { map[i][j] = k++; } } for(i=n-1; i>-1; i--) { for(j=0; j<m; j++) { printf("%d ", map[i][j]); } printf("\n"); } } */
0
0
2

노주희

더보기
bottom of page