<body>
<table border = "1">
<tr>
<td width = "50%">
<ul>
<li>list 1</li>
<li>list2</li>
<li>list3</li>
</ul>
</td>
<td width = "50%">
<ul>
<li>list4</li>
<li>list5</li>
<li>list6</li>
</ul>
</td>
</tr>
<tr>
<td>
<p>Anything in table
</p>
</td>
<td>
<p> <img src = "cloud.jpg" alt = "cloud"/></p>
</td>
</tr>
</body>
=============================================================
<audio controls autoplay>
<source src = "old_pop.ogg" type = "audio/ogg">
<source src = "old_pop.wav" type = "audio/wav">
<source src = "old_pop.mp3" type = "audio/mp3">
</audio>
=============================================================
<video controls src = "movie.mp4" >
</video>
<video src = "movie.ogg" autoplay controls>
</video>
<video width = "640" height = "480" controls>
<source src = "trailer.ogv" type ='video/ogg'>
</video>
=============================================================
<body>
<iframe src "" name ="iframe1"></iframe>
<p><a href = "http://www.w3.org" target = "iframe1">www.web</a></p>
=============================================================
<body>
<div style = "border : 3px solid red;">
<h2>lion</h2>
<p>lion lives in Africa and has strong legs and chin,
<span style = "color : red;"> 긴 송곳니</span>
를 지니고 있다.
</p>
</body>
=============================================================
<body>
<form action = "input.jsp" method = "post">
<input type = "text" name = "Text" />
<input type = "password" name = "password" />
<input type = "radio" name = "radio" />
<input type = "checkbox" name = "fruits" value = "Apple" checked >Apple
<input type = "checkbox" name = "fruits" value = "grape">grape
<input type = "range" name = "range" min="0" max = "10" step ="2"/>
<input type = "file" name = "file" >
<input type = "Reset" name = "Reset">
<input type = "image" src = "submit.png" alt ="제출 버튼">
<button type = "submit"><img src = "submit.png"></button>
<input type = "hidden" name = "hidden">
<input type = "submit" name = "submit" value = "제출">
</form>
</body>
10.31.2017
10.25.2017
10.25 C++
#include <iostream>
using namespace std;
class myvector{
private :
int *p;
int size;
int next;
public :
myvector(){
p = NULL, size = next = 0;
}
myvector(int n){
size = n;
p = new int[n];
next = 0;
}
myvector(int n, int v){
size = n;
p = new int[n];
next = n;
for(int i = 0; i < n; i++)
p[n] = v;
}
~myvector(){
if (p != NULL) delete[] p;
}
int get_size(){
return next;
}
int get_maxsize(){
return size;
}
int get_value(int i){
return p[i];
if(i <0 || i >= next){
cout << "index out of range" << endl;
return -1;
}
}
void set_value(int i , int v){
if(i < 0 || i >= next){
cout << "index out of range" << endl;
}
else p[i] = v;
}
void push_back(int v){
if (size == next){
if(p == NULL){
p = new int[10];
size = 10;
}
else
{
int *q = new int[size *2];
for(int i =0;i<size;i++){
q[i]=p[i];
}
delete[] p;
p = q;
size = size*2;
}
}
p[next++] = v;
}
void clear(){
delete[] p;
size = next = 0;
}
};
void read_data(myvector &m){
int value;
m.clear();
while(true){
cin >> value;
if(value < 0) break;
m.push_back(value);
}
}
void process(myvector &m){
int sum = 0;
for(int i = 0;i<m.get_size();i++){
sum += m.get_value(i);
}
cout << (double)sum / m.get_size() << endl;
}
int main(){
myvector a, b(20), c(16,100);
cout << a.get_maxsize() << "," << a.get_size() << endl;
cout << b.get_maxsize() << "," << b.get_size() << endl;
cout << c.get_maxsize() << "," << c.get_size() << endl;
read_data(a); process(a);
read_data(a); process(a);
return 0;
}
using namespace std;
class myvector{
private :
int *p;
int size;
int next;
public :
myvector(){
p = NULL, size = next = 0;
}
myvector(int n){
size = n;
p = new int[n];
next = 0;
}
myvector(int n, int v){
size = n;
p = new int[n];
next = n;
for(int i = 0; i < n; i++)
p[n] = v;
}
~myvector(){
if (p != NULL) delete[] p;
}
int get_size(){
return next;
}
int get_maxsize(){
return size;
}
int get_value(int i){
return p[i];
if(i <0 || i >= next){
cout << "index out of range" << endl;
return -1;
}
}
void set_value(int i , int v){
if(i < 0 || i >= next){
cout << "index out of range" << endl;
}
else p[i] = v;
}
void push_back(int v){
if (size == next){
if(p == NULL){
p = new int[10];
size = 10;
}
else
{
int *q = new int[size *2];
for(int i =0;i<size;i++){
q[i]=p[i];
}
delete[] p;
p = q;
size = size*2;
}
}
p[next++] = v;
}
void clear(){
delete[] p;
size = next = 0;
}
};
void read_data(myvector &m){
int value;
m.clear();
while(true){
cin >> value;
if(value < 0) break;
m.push_back(value);
}
}
void process(myvector &m){
int sum = 0;
for(int i = 0;i<m.get_size();i++){
sum += m.get_value(i);
}
cout << (double)sum / m.get_size() << endl;
}
int main(){
myvector a, b(20), c(16,100);
cout << a.get_maxsize() << "," << a.get_size() << endl;
cout << b.get_maxsize() << "," << b.get_size() << endl;
cout << c.get_maxsize() << "," << c.get_size() << endl;
read_data(a); process(a);
read_data(a); process(a);
return 0;
}
최종 완성본
#include <iostream>
using namespace std;
class myvector{
private :
int *p;
int size;
int next;
public :
myvector(){
p = NULL, size = next = 0;
}
myvector(int n){
size = n;
p = new int[n];
next = 0;
}
myvector(int n, int v){
size = n;
p = new int[n];
next = n;
for(int i = 0; i < n; i++)
p[n] = v;
}
~myvector(){
if (p != NULL) delete[] p;
}
int get_size(){
return next;
}
int get_maxsize(){
return size;
}
int get_value(int i){
return p[i];
if(i <0 || i >= next){
cout << "index out of range" << endl;
return -1;
}
}
void set_value(int i , int v){
if(i < 0 || i >= next){
cout << "index out of range" << endl;
}
else p[i] = v;
}
void push_back(int v){
if (size == next){
if(p == NULL){
p = new int[10];
size = 10;
}
else
{
int *q = new int[size *2];
for(int i =0;i<size;i++){
q[i]=p[i];
}
delete[] p;
p = q;
size = size*2;
}
}
p[next++] = v;
}
void clear(){
delete[] p;
size = next = 0;
}
};
void read_data(myvector &m){
int value;
m.clear();
while(true){
cin >> value;
if(value < 0) break;
m.push_back(value);
}
}
void process(myvector &m){
int sum = 0;
for(int i = 0;i<m.get_size();i++){
sum += m.get_value(i);
}
cout << (double)sum / m.get_size() << endl;
}
int main(){
myvector a, b(20), c(16,100);
cout << a.get_maxsize() << "," << a.get_size() << endl;
cout << b.get_maxsize() << "," << b.get_size() << endl;
cout << c.get_maxsize() << "," << c.get_size() << endl;
read_data(a); process(a);
read_data(a); process(a);
return 0;
}
using namespace std;
class myvector{
private :
int *p;
int size;
int next;
public :
myvector(){
p = NULL, size = next = 0;
}
myvector(int n){
size = n;
p = new int[n];
next = 0;
}
myvector(int n, int v){
size = n;
p = new int[n];
next = n;
for(int i = 0; i < n; i++)
p[n] = v;
}
~myvector(){
if (p != NULL) delete[] p;
}
int get_size(){
return next;
}
int get_maxsize(){
return size;
}
int get_value(int i){
return p[i];
if(i <0 || i >= next){
cout << "index out of range" << endl;
return -1;
}
}
void set_value(int i , int v){
if(i < 0 || i >= next){
cout << "index out of range" << endl;
}
else p[i] = v;
}
void push_back(int v){
if (size == next){
if(p == NULL){
p = new int[10];
size = 10;
}
else
{
int *q = new int[size *2];
for(int i =0;i<size;i++){
q[i]=p[i];
}
delete[] p;
p = q;
size = size*2;
}
}
p[next++] = v;
}
void clear(){
delete[] p;
size = next = 0;
}
};
void read_data(myvector &m){
int value;
m.clear();
while(true){
cin >> value;
if(value < 0) break;
m.push_back(value);
}
}
void process(myvector &m){
int sum = 0;
for(int i = 0;i<m.get_size();i++){
sum += m.get_value(i);
}
cout << (double)sum / m.get_size() << endl;
}
int main(){
myvector a, b(20), c(16,100);
cout << a.get_maxsize() << "," << a.get_size() << endl;
cout << b.get_maxsize() << "," << b.get_size() << endl;
cout << c.get_maxsize() << "," << c.get_size() << endl;
read_data(a); process(a);
read_data(a); process(a);
return 0;
}
10.24.2017
7주차 과제
<9-1>
#include <iostream>
using namespace std;
class CRectangle {
private :
double width, height;
public:
CRectangle() {
width = height = 1.0;
}
~CRectangle() {
}
CRectangle(double a, double b){
width = a, height = b;
}
double get_width() {
return width;
}
double get_height() {
return height;
}
void set_width(double a) {
width = a;
}
void set_height(double a) {
height = a;
}
double getArea() {
cout << "면적은 : " << width*height << endl;
return width*height;
}
double getPerimeter() {
cout << "둘레 길이는 : " << 2 * (width + height) << endl;
return 2 * (width + height);
}
};
int main() {
CRectangle a, b;
a.set_height(40);
a.set_width(4);
cout << "첫 번째 객체의 높이는 : " << a.get_height() << endl;
cout << "너비는 : " << a.get_width() << endl;
a.getArea();
a.getPerimeter();
b.set_height(35.9);
b.set_width(3.5);
cout << "두 번째 객체의 높이는 : " << b.get_height() << endl;
cout << "너비는 : " << b.get_width() << endl;
b.getArea();
b.getPerimeter();
system("pause");
return 0;
}
9-2
#include <iostream>
using namespace std;
class Fan {
private :
int speed;
bool on;
double radius;
public:
Fan() {
speed = 1;
on = false;
radius = 5;
}
Fan(int a, bool b, double c)
{
speed = a;
on = b;
radius = c;
}
~Fan() {
}
int get_speed() {
return speed;
}
bool get_on() {
return on;
}
double get_radius() {
return radius;
}
void set_speed(int a) {
speed = a;
}
void set_on(bool a) {
on = a;
}
void set_radius(double a) {
radius = a;
}
};
int main() {
Fan a, b;
a.set_speed(3);
a.set_on(true);
a.set_radius(10);
b.set_speed(2);
b.set_on(false);
b.set_radius(5);
cout << "Speed is : " << a.get_speed() << endl;
cout << "Is it on? (on : 1, if off : 0) : " << a.get_on() << endl;
cout << "Radius is : " << a.get_radius() << endl;
cout << "Speed is : " << b.get_speed() << endl;
cout << "Is it on? (on : 1, if off : 0) : " << b.get_on() << endl;
cout << "Radius is : " << b.get_radius() << endl;
system("pause");
return 0;
}
9-3
#include <iostream>
using namespace std;
class Account {
private :
int id;
double balance, annualInterestRate;
public :
Account() {
id = 0;
balance = annualInterestRate = 0.0;
}
Account() {
}
int get_id() {
return id;
}
double get_balance() {
return balance;
}
double get_annualInterestRate() {
return annualInterestRate;
}
void set_id(int a) {
id = a;
}
void set_balance(double a) {
balance = a;
}
void set_annualInterestRate(double a) {
annualInterestRate = a;
}
double getMonthlyInterestRate() {
return get_annualInterestRate() / 12;
}
double withdraw(double amount) {
return balance -= amount;
}
double deposit(double amount) {
return balance += amount;
}
};
int main() {
Account a;
a.set_id(1122);
a.set_balance(20000);
a.set_annualInterestRate(4.5);
a.withdraw(2500);
a.deposit(3000);
cout << "잔액 : " << a.get_balance() << endl;
cout << "월 이자 : " << a.get_balance()*a.getMonthlyInterestRate()/100 << endl;
system("pause");
return 0;
}
9-4
#include <iostream>
#include <cmath>
using namespace std;
class MyPoint {
private :
double x, y;
public :
MyPoint() {
x = y = 0.0;
}
MyPoint(double a, double b) {
x = a;
y = b;
}
~MyPoint() {
}
double get_x() {
return x;
}
double get_y() {
return y;
}
double distance(double a, double b) {
return sqrt(pow(a-x, 2) + pow(b-y,2));
}
};
int main() {
MyPoint a(0, 0.0);
MyPoint b(10, 30.5);
double distance = a.distance(b.get_x(), b.get_y());
cout << "두 점 사이의 거리는 : " << distance << endl;
system("pause");
return 0;
}
#include <iostream>
using namespace std;
class CRectangle {
private :
double width, height;
public:
CRectangle() {
width = height = 1.0;
}
~CRectangle() {
}
CRectangle(double a, double b){
width = a, height = b;
}
double get_width() {
return width;
}
double get_height() {
return height;
}
void set_width(double a) {
width = a;
}
void set_height(double a) {
height = a;
}
double getArea() {
cout << "면적은 : " << width*height << endl;
return width*height;
}
double getPerimeter() {
cout << "둘레 길이는 : " << 2 * (width + height) << endl;
return 2 * (width + height);
}
};
int main() {
CRectangle a, b;
a.set_height(40);
a.set_width(4);
cout << "첫 번째 객체의 높이는 : " << a.get_height() << endl;
cout << "너비는 : " << a.get_width() << endl;
a.getArea();
a.getPerimeter();
b.set_height(35.9);
b.set_width(3.5);
cout << "두 번째 객체의 높이는 : " << b.get_height() << endl;
cout << "너비는 : " << b.get_width() << endl;
b.getArea();
b.getPerimeter();
system("pause");
return 0;
}
9-2
#include <iostream>
using namespace std;
class Fan {
private :
int speed;
bool on;
double radius;
public:
Fan() {
speed = 1;
on = false;
radius = 5;
}
Fan(int a, bool b, double c)
{
speed = a;
on = b;
radius = c;
}
~Fan() {
}
int get_speed() {
return speed;
}
bool get_on() {
return on;
}
double get_radius() {
return radius;
}
void set_speed(int a) {
speed = a;
}
void set_on(bool a) {
on = a;
}
void set_radius(double a) {
radius = a;
}
};
int main() {
Fan a, b;
a.set_speed(3);
a.set_on(true);
a.set_radius(10);
b.set_speed(2);
b.set_on(false);
b.set_radius(5);
cout << "Speed is : " << a.get_speed() << endl;
cout << "Is it on? (on : 1, if off : 0) : " << a.get_on() << endl;
cout << "Radius is : " << a.get_radius() << endl;
cout << "Speed is : " << b.get_speed() << endl;
cout << "Is it on? (on : 1, if off : 0) : " << b.get_on() << endl;
cout << "Radius is : " << b.get_radius() << endl;
system("pause");
return 0;
}
9-3
#include <iostream>
using namespace std;
class Account {
private :
int id;
double balance, annualInterestRate;
public :
Account() {
id = 0;
balance = annualInterestRate = 0.0;
}
Account() {
}
int get_id() {
return id;
}
double get_balance() {
return balance;
}
double get_annualInterestRate() {
return annualInterestRate;
}
void set_id(int a) {
id = a;
}
void set_balance(double a) {
balance = a;
}
void set_annualInterestRate(double a) {
annualInterestRate = a;
}
double getMonthlyInterestRate() {
return get_annualInterestRate() / 12;
}
double withdraw(double amount) {
return balance -= amount;
}
double deposit(double amount) {
return balance += amount;
}
};
int main() {
Account a;
a.set_id(1122);
a.set_balance(20000);
a.set_annualInterestRate(4.5);
a.withdraw(2500);
a.deposit(3000);
cout << "잔액 : " << a.get_balance() << endl;
cout << "월 이자 : " << a.get_balance()*a.getMonthlyInterestRate()/100 << endl;
system("pause");
return 0;
}
9-4
#include <iostream>
#include <cmath>
using namespace std;
class MyPoint {
private :
double x, y;
public :
MyPoint() {
x = y = 0.0;
}
MyPoint(double a, double b) {
x = a;
y = b;
}
~MyPoint() {
}
double get_x() {
return x;
}
double get_y() {
return y;
}
double distance(double a, double b) {
return sqrt(pow(a-x, 2) + pow(b-y,2));
}
};
int main() {
MyPoint a(0, 0.0);
MyPoint b(10, 30.5);
double distance = a.distance(b.get_x(), b.get_y());
cout << "두 점 사이의 거리는 : " << distance << endl;
system("pause");
return 0;
}
9.20.2017
#include <iostream>
#include <fstream>
using namespace std;
int main() {
int num, sum = 0;
ofstream fout("out.txt");
ifstream fin("input.txt");
if (fin.fail() || fout.fail())
{
cerr << "파일 열기 에러" << endl;
return -1;
}
while (!fin.eof()) {
fin >> num;
if (fin.fail()) break;
sum += num;
}
fout.close();
fin.close();
system("pause");
return 0;
}
#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main(){
ofstream fout("C:\Users\IT333-27\Desktop\output.txt");
srand(time(0));
int num, sum = 0;
double average = 0;
int size = 5 + rand()%5;
for(int i = 0;i < size; i++){
int n = 10 + rand()%30;
cout << n << endl;
for(int j = 0; j< n ; j++){
fout << rand()%100 << " ";
}
fout << endl << endl;
}
/*average = (double)sum/num;
fout << "number of data" << num << endl;
fout << "sum : " << sum << endl;
fout << "average : " << average << endl;
fout.close();*/
return 0;
}
#include <fstream>
using namespace std;
int main() {
int num, sum = 0;
ofstream fout("out.txt");
ifstream fin("input.txt");
if (fin.fail() || fout.fail())
{
cerr << "파일 열기 에러" << endl;
return -1;
}
while (!fin.eof()) {
fin >> num;
if (fin.fail()) break;
sum += num;
}
fout.close();
fin.close();
system("pause");
return 0;
}
#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main(){
ofstream fout("C:\Users\IT333-27\Desktop\output.txt");
srand(time(0));
int num, sum = 0;
double average = 0;
int size = 5 + rand()%5;
for(int i = 0;i < size; i++){
int n = 10 + rand()%30;
cout << n << endl;
for(int j = 0; j< n ; j++){
fout << rand()%100 << " ";
}
fout << endl << endl;
}
/*average = (double)sum/num;
fout << "number of data" << num << endl;
fout << "sum : " << sum << endl;
fout << "average : " << average << endl;
fout.close();*/
return 0;
}
9.08.2017
배열과 포인터
#include <iostream>
using namespace std;
double sum = 0;
double read_data(double *data, int size) {
for (int i = 3; i < size; i++) {
cin >> *data;
cout << *data;
sum += *data;
data++;
}
return sum;
}
int main() {
double data[5];
read_data(&data[3], 5);
cout << sum<< endl;
system("pause");
return 0;
}
9.06.2017
09.06 C++
#include <iostream>
using namespace std;
int main(){
//10개의 정수를 일어들여 배열에 저장, 합과 평균을 구하여 출력하기
int arr[10];
double average = 0;
int sum = 0;
cout << "숫자 10개 입력해주세요" << endl;
for(int i = 0;i<10;i++){
cin >> arr[i];
sum += arr[i];
}
average = (double )sum/10.0;
cout << sum << ", " << average << endl;
}
=====================================================================
#include <iostream>
using namespace std;
void read_data(int data[], int size){
//배열과 배열의 크기를 인자로 주고 이 배열에 정수를 읽어들여 저장한 후 return
cout << "숫자 10개 입력" << endl;
for(int i = 0;i<size;i++){
cin >> data[i];
}
}
int sum(int data[], int size){
//배열과 배열의 크기를 인자로 주고 이 배열에 저장된 숫자의 합을 구하여 return 하기
int sum = 0;
for(int i = 0; i < size;i ++){
sum += data[i];
}
cout << sum;
return sum;
}
int main(){
int arr[10];
read_data(arr, 10);
sum(arr, 10);
}
using namespace std;
int main(){
//10개의 정수를 일어들여 배열에 저장, 합과 평균을 구하여 출력하기
int arr[10];
double average = 0;
int sum = 0;
cout << "숫자 10개 입력해주세요" << endl;
for(int i = 0;i<10;i++){
cin >> arr[i];
sum += arr[i];
}
average = (double )sum/10.0;
cout << sum << ", " << average << endl;
}
=====================================================================
#include <iostream>
using namespace std;
void read_data(int data[], int size){
//배열과 배열의 크기를 인자로 주고 이 배열에 정수를 읽어들여 저장한 후 return
cout << "숫자 10개 입력" << endl;
for(int i = 0;i<size;i++){
cin >> data[i];
}
}
int sum(int data[], int size){
//배열과 배열의 크기를 인자로 주고 이 배열에 저장된 숫자의 합을 구하여 return 하기
int sum = 0;
for(int i = 0; i < size;i ++){
sum += data[i];
}
cout << sum;
return sum;
}
int main(){
int arr[10];
read_data(arr, 10);
sum(arr, 10);
}
피드 구독하기:
글 (Atom)
