4일차_CSS

HTML/CSS 2015. 6. 21. 07:54

-------------------------------
4. Grouping Selectors
- 여러개의 선택자를 동시 사용.
- 구분자로 , (comma)를 사용.

CSS 표현 -> 선택자1, 선택자2, ... {속성:값}


5. 하위 요소 선택
CSS 표현 -> 부모선택자 > 자식선택자 {속성:값}
CSS 표현 -> 조상선택자   자손선택자 {속성:값}

<div>     부모선택자(조상선택자)
 <div>     자식선택자(자손선택자)
  <div>     자손선택자
  </div>
 </div>
</div>

6. 속성 선택
CSS 표현 -> [속성=값] {속성:값}

<a href="">
<a href="" target="">   ->   a[target=_blank] {text-tecoration:none;}
<img src="" alt="">
<img src="" alt="" width="" heigth="">     ->  img[width] {속성:값}


7. shadow 선택
- 특정 대상이 특정 상황에 놓인 경우에 한해서 선택되는 경우
CSS 표현 -> 특정대상:hover {속성:값}

- 특정 대상이 특정 위치에 놓인 경우에 한해서 선택되는 경우
CSS 표현 -> 특정대상:first-child {속성:값}


<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<style type="text/css">
 div { font-size: 10pt; color: #666666; }
 h1 { font-size: 12pt; color:#53CF7C; }
 
 /* 선택자 선택자 { 속성: 값; ... } */
 /* text-decoration 속성은 텍스트에 대한 장식 지정 */
 div#menu a { color: #666666; text-decoration: none; }
 div#menu a:hover { color: #000000; text-decoration: underline; }
</style>

</head>
<body>
<div>
 <!-- id="", class="", name="" 식별자 지정 -->
 <div id="menu">
  <h1>CSS Tutorial</h1>
  <p><a href="">CSS HOME</a></p>
  <p><a href="">CSS Introduction</a></p>
  <p><a href="">CSS Syntax</a></p>
  <p><a href="">CSS Selectors</a></p>
 </div>
</div>
</body>
</html>


-----------------------------------------------
CSS  적용 방법

1. CSS  적용 범위
- 인라인 단위 적용 방법 : 특정 태그에만 적용되는 CSS. 웹페이지 내에서 특정 부분에만 적용하는 스타일 지정시 사용.
<태그명 style="CSS속성:값; CSS속성:값; ...">데이터</태그명>


- 페이지 단위 적용 방법 : 특정 페이지에만 적용되는 CSS. 웹페이지 전체의 스타일 지정시 사용.
<style type="text/css">
 선택자 { CSS속성:값; CSS속성:값; ... }
</style>


- 파일 단위 적용 방법 : 특정 파일 단위로 적용되는 CSS. 웹사이트 전체의 스타일 지정시 사용.
<link rel="stylesheet" type="text/css" href="파일명.css">
-> 별도의 .css 파일을 만들어서 그 안에 스타일 내용을 작성한다.

 

http://www.w3schools.com/stdtheme.css

 


----------------------------------------------
CSS Text

1. color - Sets the color of text
2. line-height - Sets the line height
3. text-align - Specifies the horizontal alignment of text
4. text-decoration - Specifies the decoration added to text
5. vertical-align - Sets the vertical alignment of an element

 

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<style type="text/css">
  /* 선택자 { 속성:값; 속성:값; ...} */
  div { width: 550px; line-height: 170%;}
  h1 { font-size:15pt;}
  h2 { font-size:9pt; color:gray; font-weight: normal;}
  p { margin-top:25px; margin-bottom:25px; }
  p#img { text-align: center; }
</style>

</head>
<body>
<!-- 뉴스 기사 전체 -->
<div id="news0003251960">
 <!-- 제목 영역 -->
 <div>
  <h1>"구글 유튜브, 1조원 게임 스트리밍 서비스 인수"</h1>
  <h2>기사입력 2014-05-19 08:38 | 최종수정 2014-05-19 09:09</h2>
 </div>
 <!-- 내용 영역 -->
 <div>
  <p id="img"><img src="http://imgnews.naver.net/image/277/2014/05/19/2014051908351937334_1_99_20140519090908.jpg"></p>
  <p>[아시아경제 조유진 기자] 구글 유튜브가 비디오게임 스트리밍 서비스 트위치를 인수한다. 인수금액은 10억달러(약1조250억원)로 인수가 성사되면 전액 현금으로 지급될 예정이다. </p>
  <p>18일(현지시간) 미국 버라이어티 등 외신에 따르면 구글의 동영상 서비스 유튜브가 비디오 게임 스트리밍 업체 트위치(Twitch)를 인수하는 계약을 체결했다. </p>
  <p>이번 거래는 규제 당국의 심사를 거친 뒤 발표될 예정이다. </p>
  <p>트위치는 2011년 6월 저스틴 칸과 에미트 시어가 게임 콘텐츠에 중점을 둔 스트리밍 서비스로 시작했으며, 서비스 2년 만에 게임전용 방송국으로 인기를 얻고 있다.</p>
  <p>트위치 사이트의 월간 사용자 수는 4500만명이며, 동영상을 업로드하는 활동 이용자 수는 100만명이 넘는다.</p>
  <p>조유진 기자 tint@asiae.co.kr</p>
 </div>
</div>
</body>
</html>

 

 

 

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<style type="text/css">
 table#form01  tr > td:first-child { text-align: right; }

 input[type=text]:focus { background-color: #FFE6E6 ; }

</style>

</head>
<body>
<div>
 <h1>회원가입</h1>
 <form>
 <table id="form01">
  <tr>
   <td>이름</td><td><input type="text" placeholder="이름"></td>
  </tr>

  <!-- HTML5 전용 속성 -->
  <tr>
   <td>전화</td><td><input type="text" placeholder="010-XXXX-XXXX" pattern="010-[0-9]{4}-[0-9]{4}"></td>
  </tr>

  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>이메일</td><td><input type="email" placeholder="이메일"></td>
  </tr>

  <tr>
   <td>성별</td><td><input type="radio" name="gender" value="male">Male <input type="radio" name="gender" value="female">Female</td>
  </tr>
  <tr>
   <td>취미</td><td><input type="checkbox" value="1">운동 <input type="checkbox" value="2">여행 <input type="checkbox" value="3">감상</td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>생년월일</td><td><input type="date"></td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>수강 횟수</td><td><input type="number" min="0"></td>
  </tr>
  
  <tr>
   <td style="vertical-align: top;">자기 소개</td><td><textarea style="width: 400px; height:100px;" placeholder="간단한 자기 소개를 부탁합니다." ></textarea></td>
  </tr>
  <tr>
   <td></td><td><input type="submit"></td>
  </tr>
 </table>
 </form>
</div>
</body>
</html>

 

---------------------------------------
CSS Background

1. background-color - Sets the background color of an element
2. background-image - Sets the background image for an element
3. background-position - Sets the starting position of a background image
4. background-repeat - Sets how a background image will be repeated

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<style type="text/css">
 
 table tr > td:first-child { text-align: right;  }
 
 input[type=text]:focus { background-color:  #FFE6E6  ; }
 
 table { border: 1px solid #FFCCFF ;}
 
 tr { background-color: #FFEBFF ; }

</style>

</head>
<body>
<div>
 <h1>회원가입</h1>
 <form>
 <table id="form01">
  <tr>
   <td>이름</td><td><input type="text" placeholder="이름

"></td>
  </tr>

  <!-- HTML5 전용 속성 -->
  <tr>
   <td>전화</td><td><input type="text" placeholder="010

-XXXX-XXXX" pattern="010-[0-9]{4}-[0-9]{4}"></td>
  </tr>

  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>이메일</td><td><input type="email" placeholder="

이메일"></td>
  </tr>

  <tr>
   <td>성별</td><td><input type="radio" name="gender"

value="male">Male <input type="radio" name="gender"

value="female">Female</td>
  </tr>
  <tr>
   <td>취미</td><td><input type="checkbox" value="1">운

동 <input type="checkbox" value="2">여행 <input type="checkbox" value="3">감

상</td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>생년월일</td><td><input type="date"></td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>수강 횟수</td><td><input type="number"

min="0"></td>
  </tr>
  
  <tr>
   <td style="vertical-align: top;">자기 소개</td><td><textarea style="width: 400px;

height:100px;" placeholder="간단한 자기 소개를 부탁합니다." ></textarea></td>
  </tr>
  <tr>
   <td></td><td><input type="submit"></td>
  </tr>
 </table>
 </form>
</div>
</body>
</html>

 

 


<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<style type="text/css">
 table#form01 { background-image: url('smiley.gif') ;
     background-repeat: no-repeat;
     background-position: top right;}
 table#form01  tr > td:first-child { text-align: right; background-color: #C2C2C2; }
</style>

</head>
<body>
<div>
 <h1>회원가입</h1>
 <form>
 <table id="form01" >
  <tr>
   <td>이름</td><td><input type="text" placeholder="이름"></td>
  </tr>

  <!-- HTML5 전용 속성 -->
  <tr>
   <td>전화</td><td><input type="text" placeholder="010-XXXX-XXXX" pattern="010-[0-9]{4}-[0-9]{4}"></td>
  </tr>

  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>이메일</td><td><input type="email" placeholder="이메일"></td>
  </tr>

  <tr>
   <td>성별</td><td><input type="radio" name="gender" value="male">Male <input type="radio" name="gender" value="female">Female</td>
  </tr>
  <tr>
   <td>취미</td><td><input type="checkbox" value="1">운동 <input type="checkbox" value="2">여행 <input type="checkbox" value="3">감상</td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>생년월일</td><td><input type="date"></td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>수강 횟수</td><td><input type="number" min="0"></td>
  </tr>
  
  <tr>
   <td style="vertical-align: top;">자기 소개</td><td><textarea style="width: 400px; height:100px;" placeholder="간단한 자기 소개를 부탁합니다." ></textarea></td>
  </tr>
  <tr>
   <td style="background-color: white;"></td><td><input type="submit"></td>
  </tr>
 </table>
 </form>
</div>
</body>
</html>

 

-----------------------------------
CSS Font

1. font-size - Specifies the font size of text
2. font-style - Specifies the font style for text
3. font-family - Specifies the font family for text


-----------------------------------
CSS Tables

1. Table Borders - border: 1px solid black;
2. Collapse Borders - border-collapse:collapse;
3. Table Width and Height - width:100%; height:50px;
4. Table Text Alignment - text-align:right; vertical-align:bottom;
5. Table Padding - padding:15px;
6. Table Color - background-color:green; color:white;

 

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<style type="text/css">
 
 table { border-collapse:collapse; }
 table, td { border: 1px solid #B2CCFF; }
 td { padding: 5px; }
 
 td.back01 { background-color:#E0EBFF ;  }

</style>

</head>
<body>
<div>
 <h1>회원가입</h1>
 <form>
 <table id="form01">
  <tr>
   <td class="back01">이름</td><td><input type="text" placeholder="이름

"></td>
  </tr>

  <!-- HTML5 전용 속성 -->
  <tr>
   <td class="back01">전화</td><td><input type="text" placeholder="010

-XXXX-XXXX" pattern="010-[0-9]{4}-[0-9]{4}"></td>
  </tr>

  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td class="back01">이메일</td><td><input type="email" placeholder="

이메일"></td>
  </tr>

  <tr>
   <td class="back01">성별</td><td><input type="radio" name="gender"

value="male">Male <input type="radio" name="gender"

value="female">Female</td>
  </tr>
  <tr>
   <td class="back01">취미</td><td><input type="checkbox" value="1">운

동 <input type="checkbox" value="2">여행 <input type="checkbox" value="3">감

상</td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td class="back01">생년월일</td><td><input type="date"></td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td class="back01">수강 횟수</td><td><input type="number"

min="0"></td>
  </tr>
  
  <tr>
   <td style="vertical-align: top;" class="back01">자기 소개</td><td><textarea style="width: 400px;

height:100px;" placeholder="간단한 자기 소개를 부탁합니다." ></textarea></td>
  </tr>
  <tr>
   <td></td><td><input type="submit"></td>
  </tr>
 </table>
 </form>
</div>

</body>
</html>

 

 


//Table.css
@CHARSET "EUC-KR";
#customers
{
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
width:100%;
border-collapse:collapse;
}
#customers td, #customers th
{
font-size:1em;
border:1px solid #98bf21;
padding:3px 7px 2px 7px;
}
#customers th
{
font-size:1.1em;
text-align:left;
padding-top:5px;
padding-bottom:4px;
background-color:#A7C942;
color:#ffffff;
}
#customers tr.alt td
{
color:#000000;
background-color:#EAF2D3;
}

 

 


<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<link rel="stylesheet" type="text/css" href="Table.css">

<style type="text/css">
 table#form01 { background-image: url('back03.jpg') ;
     background-repeat: no-repeat;
     background-position: top right;}
 table#form01  tr > td:first-child { text-align: right; background-color: #C2C2C2; }
</style>

</head>
<body>
<div>
 <h1>회원가입</h1>
 <form>
 <table id="customers" >
  <tr class="alt">
   <td>이름</td><td><input type="text" placeholder="이름"></td>
  </tr>

  <!-- HTML5 전용 속성 -->
  <tr>
   <td>전화</td><td><input type="text" placeholder="010-XXXX-XXXX" pattern="010-[0-9]{4}-[0-9]{4}"></td>
  </tr>

  <!-- HTML5 전용 폼 태그 -->
  <tr class="alt">
   <td>이메일</td><td><input type="email" placeholder="이메일"></td>
  </tr>

  <tr>
   <td>성별</td><td><input type="radio" name="gender" value="male">Male <input type="radio" name="gender" value="female">Female</td>
  </tr>
  <tr class="alt">
   <td>취미</td><td><input type="checkbox" value="1">운동 <input type="checkbox" value="2">여행 <input type="checkbox" value="3">감상</td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>생년월일</td><td><input type="date"></td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr class="alt">
   <td>수강 횟수</td><td><input type="number" min="0"></td>
  </tr>
  
  <tr>
   <td style="vertical-align: top;">자기 소개</td><td><textarea style="width: 400px; height:100px;" placeholder="간단한 자기 소개를 부탁합니다." ></textarea></td>
  </tr>
  <tr class="alt">
   <td></td><td><input type="submit"></td>
  </tr>
 </table>
 </form>
</div>
</body>
</html>


--------------------------------------------
The CSS Box Model

1. Margin - Clears an area around the border. The margin does not have a background color, it is completely transparent
2. Border - A border that goes around the padding and content. The border is inherited from the color property of the box
3. Padding - Clears an area around the content. The padding is affected by the background color of the box
4. Content - The content of the box, where text and images appear

----------------------------------------------
CSS Border

1. border - Sets all the border properties in one declaration

CSS 표현 -> border : 굵기 선의종류 색상;

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<link rel="stylesheet" type="text/css" href="Table.css">

<style type="text/css">
 table#form01 { background-image: url('back03.jpg') ;
     background-repeat: no-repeat;
     background-position: top right;}
 table#form01  tr > td:first-child { text-align: right; background-color: #C2C2C2; }
 
 input { border : 1px dashed black; font-size: 13pt; }
 textarea { border : 1px dashed black; }
</style>

</head>
<body>
<div>
 <h1>회원가입</h1>
 <form>
 <table id="customers" >
  <tr class="alt">
   <td>이름</td><td><input type="text" placeholder="이름"></td>
  </tr>

  <!-- HTML5 전용 속성 -->
  <tr>
   <td>전화</td><td><input type="text" placeholder="010-XXXX-XXXX" pattern="010-[0-9]{4}-[0-9]{4}"></td>
  </tr>

  <!-- HTML5 전용 폼 태그 -->
  <tr class="alt">
   <td>이메일</td><td><input type="email" placeholder="이메일"></td>
  </tr>

  <tr>
   <td>성별</td><td><input type="radio" name="gender" value="male">Male <input type="radio" name="gender" value="female">Female</td>
  </tr>
  <tr class="alt">
   <td>취미</td><td><input type="checkbox" value="1">운동 <input type="checkbox" value="2">여행 <input type="checkbox" value="3">감상</td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr>
   <td>생년월일</td><td><input type="date"></td>
  </tr>
  
  <!-- HTML5 전용 폼 태그 -->
  <tr class="alt">
   <td>수강 횟수</td><td><input type="number" min="0"></td>
  </tr>
  
  <tr>
   <td style="vertical-align: top;">자기 소개</td><td><textarea style="width: 400px; height:100px;" placeholder="간단한 자기 소개를 부탁합니다." ></textarea></td>
  </tr>
  <tr class="alt">
   <td></td><td><input type="submit"></td>
  </tr>
 </table>
 </form>
</div>
</body>
</html>

 

------------------------------------------
CSS Margin

1. margin - A shorthand property for setting the margin properties in one declaration

CSS 표현 -> margin: 값; margin: 값1 값2 값3 값4;

 

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<style type="text/css">
 div#main { width: 912px; margin: auto; }
 div#header { margin:3px; height: 100px; background-color: #FFCCCC;}
 div#menu { margin:3px; float:left; height: 300px; width: 200px; background-color: #CCFFCC;}
 div#content { margin:3px; float: left; height: 300px; width: 700px; background-color: #C2D6FF;}
 div#footer { margin:3px; clear:both; height:50px; background-color: #D1FFF0 ; }
</style>

</head>
<body>
<!-- 전체 영역을 하나의 큰 틀로 묶는다 -->
<div id="main">

<!-- 화면 상단부 - 주로 메인메뉴 또는 타이틀 표시하는 영역 -->
<div id="header"><h1>Main Title of Web Page</h1></div>

<!-- 서브메뉴 영역-메뉴 목록 출력하는 영역 -->
<div id="menu">
 <h2>Menu</h2>
 <ol>
  <li>HTML</li>
  <li>CSS</li>
  <li>JavaScript</li>
 </ol>
</div>

<!-- 콘텐츠 영역-페이지마다 다른 내용의 콘텐츠가 출력되는 영역 -->
<div id="content">Content goes here</div>

<!-- 화면 하단부 - 회사 이름 등이 출력되는 영역 -->
<div id="footer">Copyright (c) W3Schools.com</div>

</div>
</body>
</html>


-----------------------------------------
CSS Padding

1. padding - A shorthand property for setting all the padding properties in one declaration

CSS 표현 -> padding: 값; padding: 값1 값2 값3 값4;


<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<style type="text/css">

 div { font-size: 10pt; color: #666666; }
 h1 { font-size: 12pt; color:#53CF7C; }
 div#menu a { color: #666666; text-decoration: none; }

 p { border: 1px solid  #B2CCFF;
   width: 200px;
   padding: 5px;
   margin-top : 1px;
   margin-bottom : 1px; }
   
 p:hover { color: #000000; text-decoration: underline;
    background-color:#E0EBFF ; }

</style>

</head>
<body>
<div>
 <div id="menu">
  <h1>CSS Tutorial</h1>
  <p><a href="">CSS HOME</a></p>
  <p><a href="">CSS Introduction</a></p>
  <p><a href="">CSS Syntax</a></p>
  <p><a href="">CSS Selectors</a></p>
 </div>
</div>
</body>
</html>

 

 

---------------------------------------------------
CSS Navigation Bar

 

//Menu.css
@CHARSET "EUC-KR";
ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
li
{
float:left;
}
a:link,a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#FFFFFF;
background-color:#98bf21;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active
{
background-color:#7A991A;
}

 

 


<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<link rel="stylesheet" type="text/css" href="Menu.css">

</head>
<body>
<div>
 <h1>w3schools.com</h1>
 <div>
  <ul>
   <li><a href="">HOME</a></li>
   <li><a href="">HTML</a></li>
   <li><a href="">CSS</a></li>
   <li><a href="">JAVASCRIPT</a></li>
   <li><a href="">MORE...</a></li>
  </ul> 
 </div>

</div>
</body>
</html>

 

------------------------------------------------

블로그 이미지

알 수 없는 사용자

,

-------------------------------------------
HTML 태그의 종류

7. HTML Lists
- 순서 있는 목록, 순서 없는 목록. 블럭 요소.
- <ul>, <li>
- <ol>, <li>
- <ul>, <ol> 내부에는 <li> 태그만 가능. 콘텐츠 추가는 <li> 태그 내부에 작성.
예를 들어, 강사의 강의 가능 과목 리스트 출력시

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample10</title>

<style type="text/css">
 /* 선택자 { 속성:값; .... } */
 /* font-size 속성은 글자 크기 지정 */
 h1 { font-size: 17pt; }
 li { font-size: 14pt; }
</style>

</head>
<body>
<div>
 <h1>[홍길동] 강사 강의 가능 과목</h1>
 <!--
 목록 콘텐츠 표현 태그
 ol, ul 태그 안에 li 태그를 나열
  -->
 <ol style="list-style-type: upper-roman;">
  <li>Java SE</li>
  <li>Oracle
   <!--
   ol, ul 안에 또다른 ol, ul 표기하는 경우
   들여쓰기 지정
    --> 
   <ul style="list-style-type: square;">
    <li>User Schema</li>
    <li>DML</li>
    <li>DDL</li>
    <li>DCL</li>
   </ul>
  </li>
  <li>JDBC</li>
  <li>HTML, CSS, Javascript</li>
 </ol> 
</div>
</body>
</html>

 

--------------------------------------
8. HTML Blocks
- <div> : 블럭 요소. 항목 여러개를 그룹으로 묶어주는 역할. 범위 지정시 사용. 화면상의 레이아웃 구성시 사용.
- <span> : 인라인 요소. 범위 지정시 사용.


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample10</title>

<style type="text/css">
 /* 선택자 { 속성:값; .... } */
 /* font-size 속성은 글자 크기 지정 */
 h1 { font-size: 17pt; }
 li { font-size: 14pt; }
</style>

</head>
<body>
<div>
 <h1>[홍길동] 강사 강의 가능 과목</h1>
 <!--
 목록 콘텐츠 표현 태그
 ol, ul 태그 안에 li 태그를 나열
  -->
 <ol style="list-style-type: upper-roman;">
  <li>Java SE</li>
  <li>Oracle
   <!--
   ol, ul 안에 또다른 ol, ul 표기하는 경우
   들여쓰기 지정
    --> 
   <ul style="list-style-type: square;">
    <li>User Schema</li>
    <li>DML</li>
    <li>DDL</li>
    <li>DCL</li>
   </ul>
  </li>
  <li>JDBC</li>
  <li>HTML, CSS, Javascript</li>
 </ol>
 
 
 <!--
 인라인 스타일.
 특정 태그에만 스타일 지정시 style="속성:값;..." 속성 추가.
 background-color 속성은 배경색 지정.
 color 속성은 전경색 지정.
 padding 속성은 내부 여백 지정.
 width 속성은 블럭의 너비 지정.
 절대적, 상대적 크기 지정 가능.
 -->
 <div style="background-color:black; color:white; padding:20px; width: 500px;">
 
 <h2>자기소개</h2>
 <p>홍길동 강사의 자기 소개 내용....</p>
 
 </div> 
 
  
</div>
</body>
</html>

 

http://m.naver.com 사이트 에서 블럭요소 분석.

 

---------------------------------------
9. HTML Layouts

레이아웃은 화면의 구성 요소를 적당한 크기로 나눠서 지정하는 것.
화면상단부, 메뉴부, 콘텐츠부, 화면하단부 등으로 구분하는 것.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample11</title>

<style type="text/css">
 /* 선택자 { 속성:값; ... } */
 
 /* #menu 은 id="menu" 속성을 가진 태그를 접근하는 추가 속성 */
 /* height 속성은 블럭의 (절대적)높이 지정 */
 /* min-height 속성은 블럭의 (상대적)높이 지정. 최소 높이 지정. */
 /* text-align 속성은 정렬 위치 지정 */
 /* margin:auto; 속성은 블럭 요소를 가운데 정렬 시켜준다 */
 div#menu { margin:auto;   min-height:100px; text-align: center; background-color: gray; width:80%;  }
 div#content { margin:auto; min-height:300px; width:80%;  }
 div#copyright { margin:auto; min-height:50px;  text-align: center; width:80%; background-color: gray;}
 
</style>

</head>
<body>
<!-- 전체 영역 지정 -->
<!-- id 속성은 영역에 대한 식별자 지정. 스타일 지정시 사용 예정. -->
<div id="main">

<!-- 상단 영역 지정. 주메뉴 출력. 페이지에 상관없이 고정. -->
<div id="menu">
 <h1>[홍길동] 강사 강의 가능 과목</h1>
</div>

<!-- 콘텐츠 영역 지정. 내용 출력. 페이지별로 작성. -->
<div id="content">
</div>

<!-- 하단 영역 지정. 회사소개 출력. 페이지에 상관없이 고정. -->
<div id="copyright">
  회사소개
</div>


</div>
</body>
</html>

 

 


---------------------------------------------
10. ***HTML Forms and Input
- 입력 폼 구성 태그.
- 이름, 전화번호 등을 입력 받는 화면 구성시 사용.
- <form> : 입력 폼 태그 전체의 부모 요소. 블럭 요소.
- <input> : 사용자의 데이터를 입력 받는 입력 폼 태그. type="" 속성 종류가 다양하게 준비되어 있다. text, password, checkbox, radio, .... 인라인 요소.
- <select> : 사용자로부터 미리 정해진 데이터 중에 하나를 선택하도록 하는 태그. 인라인 요소.
- <textarea> : 사용자로부터 다량의 문자 데이터를 입력받는 입력 폼 태그. 인라인 요소.
- <input type="submit"> : 입력 폼에 입력된 데이터를 서버에 전송하는 역할을 하는 버튼. 입력 폼의 필수 구성 요소.

예를 들어, 사용자로부터 이름, 전화번호, 이메일 등을 입력받는 화면을 구성한다면


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div>
 <h1>회원가입</h1>
 <!-- 폼 태그 부모 요소 지정. <form> 태그로 지정. -->
 <form>
  <!-- 하위 요소로 <input>, <select>, <textarea> 태그 추가 -->
  <!-- 입력 받고자 하는 항목을 하위 요소로 표현. -->
  <!-- 제출(submit) 버튼 추가 되어야 액션 진행 가능 -->
  <!-- 제출 액션이 정상적으로 진행되려면
   서버 측에서 액션 전용 프로그램 추가 필요 -->
  <!-- 일반적인 텍스트 자료는 <input type="text">로 입력 받는다. -->
  이름 <input type="text">
  전화 <input type="text">
  이메일 <input type="text">
  <input type="submit">
 </form>
</div>

</body>
</html>

 


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<style type="text/css">
 /* 선택자 { 속성:값; ... } */
 /* .msg 선택자는 특정 태그에 class="msg" 식별자가 있는 경우 접근 */
 .msg { font-size:10pt; color:gray; }
 
 /* 선택자, 선택자 표기는 두 개 이상의 선택자 동시 지정하는 경우 */
 th, td { padding:3px; }
 
</style>

</head>
<body>
<div>
 <h1>회원가입</h1>
 
 <form>
 <table>
  <tr>
   <!-- <th> 태그는 제목 지정시 사용 -->
   <!-- <td> 태그는 콘텐츠 지정시 사용 -->
   <th>이름</th>
   <td>
    <!-- 글자수 제한 지정. maxlength="" 속성 추가 -->
    <input type="text" maxlength="20">
    <!-- <span></span> 태그는 인라인 요소 지정 전용 태그 -->
    <!-- class="msg" 스타일 지정을 위한 전용 식별자 -->
    <!-- id="" 속성은 고유한 이름 지정 -->
    <!-- class="" 속성은 같은 이름 사용 가능. 그룹 지정. -->
    <span class="msg">(20자 이내)</span>
   </td>
  </tr>
  <tr>
   <th>전화</th>
   <td><input type="text" maxlength="20"><span class="msg"> (20자 이내)</span></td>
  </tr>
  <tr>
   <th>이메일</th>
   <td>
    <!-- 폼의 너비 지정. size="글자수" 속성 또는 style="width:너비;" 지정. -->
    <input type="text" size="50" maxlength="50">
    <span class="msg"> (50자 이내)</span>
   </td>
  </tr>
  <tr>
   <th>입사일</th>
   <td>
    <!--
    type="date" 속성은 HTML5 전용.
    년-월-일 서식 강제 지정 및 달력 출력 가능.
    범용적인 상황이 아닌 속성은 권장하지 않는다.
    - jQuery 권장
     -->
    <input type="date"> (YYYY-MM-DD)
   </td>
  </tr>
  <tr>
   <th>지역</th>
   <td>
    <!--
    특정 범위 내에서 선택하는 경우
    라디오(단일선택)
    , 체크박스(다중선택)
    , 선택목록(단일선택, 다중선택) 태그 사용.
    라디오 태그 사용시 name="식별자" 속성 필수 지정.
     -->
    <input type="radio" name="city">서울
    <input type="radio" name="city">부산
    <input type="radio" name="city">인천
   </td>
  </tr>
  <tr>
   <th>부서</th>
   <td>
    <!-- 선택목록(단일선택, 다중선택) 태그 사용. -->
    <select>
     <option>개발부</option>
     <option>마케팅부</option>
     <option>총무부</option>
    </select>
   </td>
  </tr>
  <tr>
   <th>취미</th>
   <td>
    <!-- 다중 선택인 경우 체크박스 지정 -->
    <input type="checkbox" >영화
    <input type="checkbox">독서
    <input type="checkbox">스포츠
    <input type="checkbox">게임
   </td>
  </tr>
  <tr>
   <th>
    자기 소개
    <br><span class="msg">(100자 이내)</span>
   </th>
   <td>
    <!--
    많은 양의 텍스트를 입력받는 경우 <textarea> 태그 사용.
    <textarea> 태그는 </textarea> 끝 태그 지정 필수.
    <textarea> 태그에서의 maxlength="" 속성은 HTML5 전용.
    -->
    <textarea cols="50" rows="5" maxlength="100"></textarea>
    <!-- 입력되는 글자의 수를 출력하는 부분 추가. Javascript 이용. -->
    <span style="font-size:10pt; color:red;">(0/100)</span>
   </td>
  </tr>
  <tr>
   <td></td>
   <td><input type="submit"></td>
  </tr>
 </table>
 </form>
</div>

</body>
</html>


-----------------------------------------------
11. HTML Iframes

브라우저 영역 내에서 독립적인 브라우저 영역을 만드는 태그.

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<div>
 <h1>[홍길동] 강사 강의 스케줄</h1>
 <p><a href="Sample12.html" target="schedule">예정</a>
    <a href="Sample11.html" target="schedule">진행</a>
    <a href="Sample10.html" target="schedule">완료</a></p>
 <iframe width="500" height="300" name="schedule"></iframe>
</div>
</body>
</html>

 

----------------------------------------------
CSS (Cascading Style Sheets)

1. HTML 태그만으로는 표현 부분이 부족하기 때문에 CSS를 이용해서 출력 형태를 지정하게 된다.

2. CSS 기본 형식
"CSS 속성명 : 값" 형태의 명령을 특정 대상에 적용하면 지정된 속성에 따라 출력 형태가 달라진다.
예를 들어,  "color:red" 명령을 이용하면 특정 대상의 전경색이 빨간색으로 출력된다.

3. CSS 적용 방법
- 인라인 단위 적용 방법 : 특정 태그에만 적용되는 CSS. 웹페이지 내에서 특정 부분에만 적용하는 스타일 지정시 사용.
- 페이지 단위 적용 방법 : 특정 페이지에만 적용되는 CSS. 웹페이지 전체의 스타일 지정시 사용.
- 파일 단위 적용 방법 : 특정 파일 단위로 적용되는 CSS. 웹사이트 전체의 스타일 지정시 사용.

4. 인라인 단위 적용 방법
<태그명 style="CSS속성:값; CSS속성:값; ...">데이터</태그명>

5. 페이지 단위 적용 방법
<style type="text/css">
 선택자 { CSS속성:값; CSS속성:값; ... }
</style>
-> 선택자는 여러가지 표현에 의해 특정 태그를 찾는 명령이다. 한 개 이상의 태그를 동시에 찾을 수 있다.

6. 파일 단위 적용 방법
<link rel="stylesheet" type="text/css" href="파일명.css">
-> 별도의 .css 파일을 만들어서 그 안에 스타일 내용을 작성한다.


-----------------------------------------
CSS Selectors
- CSS 적용 대상을 찾는 방법

1. The element Selector
- 태그이름을 기준으로 CSS 적용 대상을 찾는 방법.

CSS 내용 -> p {속성:값;}
예를 들어, 아래와 같은 CSS를 만들게 되면
p    /*모든 p 태그가 영향을 받는다.*/
{
text-align:center;   /*정렬 옵션*/
color:red;           /*전경색 지정*/
}


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<style type="text/css">
 /* 엘리먼트 선택자는 태그 이름을 지정한다. */
 /* 태그이름 { 속성:값;.... } */
 h1 { font-size:15pt; }
 p { text-align:center;  color:gray; }
</style>

</head>
<body>
<div>
 <h1>The element Selector</h1>
 <p>The element selector selects elements based on the element name.</p>
 <p style="color:black;">You can select all &lt;p&gt; elements on a page like this: (all &lt;p&gt; elements will be center-aligned, with a red text color)</p>
</div>
</body>
</html>


2. id Selector
- 특정 태그에 id="" 속성이 지정된 경우 id명을 이용해서 CSS 적용 대상을 찾게 된다.
- id명은 현재 페이지 내에서 유일한 이름을 가져야 한다.

CSS -> #식별자 {속성:값}
태그 -> <태그명  id="식별자"></태그명>

예를 들어,
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<style type="text/css">
 h1 { font-size:15pt; }
 p { text-align:center;  color:gray; }
 #style01 { color:black; }
</style>

</head>
<body>
<div>
 <h1>The element Selector</h1>
 <p>The element selector selects elements based on the element name.</p>
 <p id="style01">You can select all &lt;p&gt; elements on a page like this: (all &lt;p&gt; elements will be center-aligned, with a red text color)</p>
</div>
</body>
</html>


3. class Selector
- 특정 태그에 class="" 속성이 지정된 경우 class명을 이용해서 CSS 적용 대상을 찾게 된다.
- class명은 현재 페이지 내에서 중복된 이름을 가질수 있다.
- 여러개의 적용 대상을 같은 class명을 지정하면 한꺼번에 적용할 수 있다.

CSS -> .식별자 {속성:값}
태그 -> <태그명  class="식별자"></태그명>

예를 들어, 특정 태그가 여러개 있는 경우, 부분적으로 CSS 적용을 한다면

p {속성:값1}
p#id1 {속성:값2}
p.class1 {속성:값3}

<p id="id1">적용대상1</p>            -> 값2
<p class="class1">적용대상2</p>      -> 값3
<p class="class1">적용대상3</p>      -> 값3
<p>적용대상4</p>                     -> 값1
<p>적용대상5</p>                     -> 값1

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<style type="text/css">
 td.title { background-color: #FFCCCC;}
</style>

</head>
<body>
<div>
 <h1>회원 가입 화면</h1>

<form> 
<table>
  <tr>
   <td class="title">이름</td><td><input type="text" placeholder="이름

"></td>
  </tr>
  <tr>
   <td class="title">전화</td><td>
   <select>
    <option>010</option>
    <option>011</option>
    <option>017</option>
    <option>018</option>
   </select>-
   <input type="text" placeholder="전화

"></td>
  </tr>
  <tr>
   <td class="title">이메일</td><td><input type="text" placeholder="이

메일"></td>
  </tr>
  
  <tr>
   <td class="title">생년월일</td><td><input type="date"></td>
  </tr>
  
  <tr>
   <td class="title">성별</td><td><input type="radio" name="gender"

value="male">Male <input type="radio" name="gender"

value="female">Female</td>
  </tr> 
  
  <tr>
   <td class="title">취미</td><td><input type="checkbox" value="1">운

동 <input type="checkbox" value="2">여행 <input type="checkbox" value="3">감

상</td>
  </tr>
  
  <tr>
   <td class="title">자기 소개</td><td><textarea style="width: 400px;

height:100px;" placeholder="간단한 자기 소개를 부탁합니다."></textarea></td>
  </tr>  
  
  <tr>
   <td></td><td><input type="submit"></td>
  </tr> 
  
 </table> 
</form>
 
</div>
</body>
</html>


----------------------------------------------------

 

 

 

 

'HTML/CSS' 카테고리의 다른 글

4일차_CSS  (0) 2015.06.21
2일차_HTML 태그의 종류  (1) 2015.06.21
1일차_웹어플리케이션개요, HTML개요, CSS개요.txt  (0) 2015.06.21
09일차_거품정렬,선택정렬,삽입정렬  (0) 2015.06.21
블로그 이미지

알 수 없는 사용자

,

-------------------------------------------
HTML 태그의 종류

1. HTML Text Formatting
- <b> : 굵은 글씨 표현. 강조 표현.
- <i> : 이탤릭 글씨 표현
- <em> : 강조 표시
- <code> : 프로그램 코드 표현
- <sub>, <sup> : 첨자 표현
- <pre> : 입력된 모양 그대로 출력되도록 한다.
- CSS 대체 권장


//Sample05.html
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>


</head>
<body>
 <div>
  <p>
   <b>This text is bold</b>
  </p>
  <p>
   <strong>This text is strong</strong>
  </p>
  <p>
   <i>This text is italic</i>
  </p>
  <p>
   <em>This text is emphasized</em>
  </p>
  <p>
   <code>This is computer output</code>
  </p>
  <p>
   This is<sub> subscript</sub> and <sup>superscript</sup>
  </p>
  
  
 </div>
</body>
</html>

 

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<style type="text/css">
 h1 { font-size:14pt; }
 pre { background-color: #E0E0E3 ; padding:30px; }
</style>


</head>
<body>
<div>
 <h1>JAVA - 데이터베이스 연결 코드 </h1>
 <div>

 <!--
 브라우저는 줄바꿈문자, 공백문자, 탭문자를 인식하지 않기 때문에
 줄바꿈문자, 공백문자가 들어있는 페이지를 출력하는 경우는
 pre 태그 등으로 감싸준다.
  -->
 <pre>
 <code>
package com.test;

import java.sql.*;

public class DBConn {
 
 private static Connection conn;
 
 public static Connection getConnection() throws ClassNotFoundException, SQLException {
  if (conn == null) {
   Class.forName("oracle.jdbc.driver.OracleDriver");
   String url = "jdbc:oracle:thin:username/password@IPaddress:portNumber:SID";
   conn = DriverManager.getConnection(url);
  }
  return conn;
 }
 
 public static void close() throws SQLException {
  if (conn != null && !conn.isClosed()) {
   conn.close();
  }
  conn = null;
 }

}
 </code>
 </pre>  
 </div>
</div>
</body>
</html>

 

2. HTML Comments
- <!-- and -->
- 이클립스에서는 Ctrl + Shift + /  키로 대체. 주석 해제는 Ctrl + Shift + \
- <!--[if IE 8]>
    .... some HTML here ....
<![endif]-->


3. ***HTML Links
- <a> : 하이퍼링크 기능 지정. 인라인 요소. 인라인 요소는 반드시 블럭 요소로 감싸져 있어야 한다.
- <a href="url">Link text</a>
- url은 http://URL주소 형태로 작성.
예를 들어,
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_formatting
http://www.w3schools.com/images/w3logotest2.png
- url은 상대주소를 지정하게 된다.
예를 들어,
<a href="#tips">Visit the Useful Tips Section</a>

<a href="http://www.w3schools.com/html_links.htm#tips">
Visit the Useful Tips Section</a>
와 같은 의미가 된다.
- target 속성을 추가하면 새 창에 연결된다.
<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>

Sample05.html과 Sample06.html이 같은 디렉토리에 존재한다고 가정한다.
Sample05.html과 Sample06.html를 서로 연결하는 링크 추가 예정.

//Sample05.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div>
 <h1>팀원 소개 페이지</h1>
 <div>
  <!--
  하이퍼링크 연결 태그. 인라인 요소.
  링크를 클릭하면 현재 브라우저에서 다른 페이지가 연결된다.
  target="_blank" 속성 추가시 새로운 창에 연결된다.
  -->
  
  <!-- 같은 서버 내의 다른 페이지 연결 -->
  <a href="Sample05.html" target="_blank">팀원1</a>
  
  <!-- 다른 서버의 다른 페이지 연결 -->
  <a href="http://www.naver.com" target="_blank">팀원2</a>
  
 </div>
</div>

</body>

 


--------------------------------------------
4. HTML Head
- <head> : 웹페이지의 기본 정보를 저장하는 영역. 브라우저는 이 영역의 정보를 해석해서 웹페이지를 보여주게 된다.
- <title> : 웹페이지의 제목 지정
- <link> : 외부 CSS 파일 등을 연결
- <style> : CSS 지정시 사용
- <meta> : 한글 인코딩 지정
예를 들어,
<meta charset="EUC-KR"> 를 지정해야 한글을 정상적으로 볼 수 있다. 한글 인코딩은 EUC-KR, UTF-8을 사용할 수 있다. UTF-8 권장.
- <script> : 자바 스크립트 지정

 

 

 

------------------------------------
5. ***HTML Images
- <img> : 물리적으로 준비된 이미지를 웹 페이지에 표현할 때 사용. 인라인 요소.
예를 들어,
<img src="url" alt="some_text">
src="" 속성에 물리적인 이미지 경로를 지정한다.
alt="" 속성에 물리적인 이미지가 연결되지 않을 때 사용하는 대체 문자를 지정.
- 확장자는 .jpg, .gif, .png 중에 한 가지 사용. 용량 문제.
- 이미지는 물리적인 실제 크기를 적절한 크기로 사용하는 것을 권장.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div>
 <h1>그림 소개 페이지</h1>
 <div>
  <!--
  이미지 표현 태그.
  src="" 속성에 이미지 출처 표시.
  같은 서버 내에 있는 이미지인 경우 src="이미지이름.확장자"
   -->
  <img src="Hydrangeas_small.jpg">
 </div>
 <div>
  <!-- 다른 서버 내에 있는 이미지인 경우 src="http://서버주소/이미지이름.확장자" -->
  <img src="http://imgnews.naver.net/image/366/2015/04/20/2015042002004_1_99_20150420143406.jpg?type=w540">
 </div>
 
 
</div>
</body>
</html>

 


------------------------------------
6. ***HTML Tables
- <table>, <tr>, <td> : 표 형태의 콘텐츠 배치 지정시 사용. 블럭 요소.
- <th> : 표 내부에서 제목 지정시
- <tbody>, <thead>, <tfoot> : 표 전체의 제목 지정시
예를 들어,
번호와 이름, 전화번호를 출력하는 웹페이지를 작성한다면
아래와 같은 형식으로 출력되어야 한다.

번호 이름   전화번호
1    홍길동 010-111-1111
2    김길동 010-222-2222

//Sample09.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<style type="text/css">
/* width 속성은 블럭 요소의 너비 지정 */
/* padding 속성은 여백 지정 */
/* border 속성은 블럭 요소의 경계선 지정 */
/* border-collapse 속성은 경계선 내부의 틈을 지정 */
/* text-align 속성은 블럭 영역 내에서 콘텐츠의 배치 지정 */
/* background-color 속성은 블럭 영역 내에서 배경색 지정 */
 
table {
    width:50%;
}
table, th, td {
    border: 1px dashed black;
    border-collapse: collapse;
}
th, td {
    padding: 5px;
    text-align: center;
}
table#t01 tr:nth-child(even) {
    background-color: #eee;
}
table#t01 tr:nth-child(odd) {
   background-color:#fff;
}
table#t01 th {
    background-color: black;
    color: white;
}
 
</style>

</head>
<body>
<div>
 <h1>회원 명단</h1>

 <!-- 테이블 태그를 이용한 표 형태의 콘텐츠 표시 --> 
 <!--
 table 태그는 전체의 부모 요소.
 tr 태그는 ROW 지정 태그.
 th, td 태그는 COLUMN 지정 태그.
 th 태그는 제목 지정시 사용.
  -->
 <table id="t01">
  <tr>
   <th>NAME</th><th>TELEPHONE</th><th>EMAIL</th>
  </tr>
  <tr>
   <td>홍길동</td><td>010-123-1234</td><td>hong@test.com</td>
  </tr>
  <tr>
   <td>박길동</td><td>010-345-3456</td><td>park@test.com</td>
  </tr>
 </table>

</div>
</body>
</html>

-------------------------------------------
스타일 파일 (BasicStyle.css) 작성

@CHARSET "EUC-KR";

/* 테이블 기본 스타일 */
table, tr, td { border:1px solid gray; border-collapse:collapse;}
td { padding: 5px; text-align: center; }
tr.tr01 { background-color: gray; color: white; font-weight: bold;}
tr.tr02 { background-color: #e5e5e5; }


---------------------------------------------

 

 

블로그 이미지

알 수 없는 사용자

,

------------------------------------------
웹 어플리케이션

1. 웹 어플리케이션의 특징

웹클라이언트                 웹서버
---------------------------------------
브라우저(IE, FF, CR)         Apache Tomcat(Java기반)
1.요청(웹주소-영문도메인, IP주소)                        
                             2.응답 및 결과 반환
                             HTML,CSS,Javascript,JSP,Servlet
3.반환된 결과 출력
HTML,CSS,Javascript -> 웹페이지
---------------------------------------

영문도메인<->IP주소 (DNS서버)

http://www.naver.com
http://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=105&oid=001&aid=0006915455
http://211.63.89.XX:8095

 

2. 웹서버 다운로드 및 설치
http://tomcat.apache.org 사이트에서 다운로드 및 압축 풀기
32-bit Windows zip (pgp, md5)


3. 이클립스와 톰캣 서버 연결
- Dynamic Web Project 생성
- Project name: 항목 입력
- Target runtime: 항목 선택(톰캣 서버 연결) -> New Runtime 버튼 선택
- Finish 버튼
- Servers 탭
- create new servers... -> Tomcat 서버 선택 -> Finish 버튼
- server.xml -> 포트 번호 변경(8080->8090)
- Servers 탭에서 서버 실행 (방화벽 허용)

4. 샘플 페이지 작성 및 실행
- Dynamic Web Project에서  WebContent 폴더 하위에 html 확장자를 가진 페이지 작성.
- Sample01.html 페이지 작성
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

Hello, Web World!

</body>
</html>
- Sample01.html 페이지 선택한 후, Run As> Run on Server 메뉴 선택
(브라우저에 http://localhost:8090/WebBasic/Sample01.html 주소 요청해도 된다.)
- 브라우저가 실행되고, 자동으로 요청 주소를 요청하게 된다.
- 웹페이지 결과 출력되면 성공.
- 톰캣 서버에 프로젝트를 등록해야 한다.

- 원격 연결 주소
http://IP주소:8090/프로젝트이름/파일이름.html


5. 한글 인코딩 설정
- EUC-KR에서 UTF-8 로 설정 변경

 

---------------------------------------------
HTML(Hyper Text Markup Language)

1. 웹페이지 작성용 언어. Markup Language의 한 종류.
태그(<태그명>) 형태의 명령으로 구성된 언어.
마크업 언어는 특정 데이터를 표식하는 언어.
예를 들어,

홍길동 -> 데이터 자체
<이름>홍길동</이름> -> 태그로 표시된 데이터 형식.


1234 ->  데이터 자체
<지역코드>1234</지역코드>


2. HTML 기본 구성
<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8">
  <title>Insert title here</title>
 </head>
 <body>
   콘텐츠 작성 영역
 </body>
</html>

3. 마크업 언어의 기본 규칙
- <태그명>데이터</태그명> : 시작 태그와 끝 태그의 쌍으로 구성.
- 태그명은 식별자 작성 규칙에 맞춰서 작성. 일반적으로 소문자 사용.
- 부모 태그와 자식 태그로 구성될 수 있다. 최상위 부모를 루트라고 한다.
예를 들어,
<루트>
 <부모태그>
  <자식태그></자식태그>
 </부모태그>
</루트>
- 태그 안에는 부가적인 정보를 위해서 속성을 추가할 수 있다.
예를 들어,
<태그명 속성="값" 속성="값" ...>데이터</태그명>


---------------------------------------------------
웹페이지 작성 규칙

- 구조 설계 : HTML. 데이터 간의 부모 자식 관계를 설정.
예를 들어,
제 1 장 큰 제목-> 제 1 절  작은 제목 -> 항 -> 목
- 표현 추가 : CSS. 데이터를 출력 형태를 지정.
- 동적 액션 추가 : Javascript. 데이터에 대한 추가적인 액션. 사용자의 대한 요청 처리. 예를 들어, 버튼 클릭 액션에 대한 반응으로 데이터 출력.


주의)
1. 웹페이지 작성시 모양(표현) 보다는 구조(레이아웃)를 먼저 생각한다. 제목, 내용 단위로 지정.
2. 모양(표현) 지정이 필요한 경우는 모두 CSS로 작성.
3. 웹페이지 특성상 Enter키, 공백은 표현되지 않는다. 대체 수단은 존재한다.
4. Line Break 특성인 <br> 태그 사용은 최소화.
5. 웹페이지 전체에 대한 구조 설계는 <div> 태그 이용.
6. 웹페이지 전체는 페이지 레이아웃 요건(상단, 중단, 하단 레이아웃)에 맞춰서 작성.


---------------------------------------
HTML 버전

HTML5
<!DOCTYPE html>

HTML 4.01
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

XHTML 1.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

----------------------------------------
태그의 종류

1. Block 요소 : 태그 사용의 범위가 블럭 형태를 가지는 태그
예를 들어, <div> 태그를 사용하면 자기 자신의 범위가 블럭이므로 다른 태그와 같은 라인에 존재할 수 없다. 상하로만 존재 가능한 상태.

2. Inline 요소 : 태그 사용의 범위가 라인 형태를 가지는 태그
예를 들어, <span> 태그를 사용하면 자기 자신의 범위가 인라인이므로 다른 태그와 같은 라인에 존재할 수 있다. 좌우로 존재 가능한 상태.


<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<div>블럭요소1</div><div>블럭요소2</div><div>블럭요소3</div>
<div>
<span>인라인요소1</span><span>인라인요소2</span><span>인라인요소3</span>
</div>
</body>
</html>


----------------------------------------
HTML Headings

1. <hn> : n은 1~6. 제목 지정시 사용하는 태그. 블럭 요소.
예를 들어, 가장 큰 제목은 <h1> 으로 지정하고, 작은 제목을 내려갈수록 번호를 증가시킨다.

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
</body>
</html>


-----------------------------------
HTML Paragraphs

1. <p>. 문단 지정시 사용하는 태그. 블럭 요소.
예를 들어, 뉴스 페이지 작성시 부모 요소 지정을 위한 <div> 태그와 제목 지정을 위한 <h> 태그, 내용 지정을 위한 <p> 태그를 혼용해서 아래와 같이 작성하게 된다. 적절한 부모 요소를 지정하는 것이 구조적 설계의 기본 구성이 된다. 부모 요소는 블럭 요소만 가능하다.
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<div id="new01">
 <h1>"페이스북, 비디오챗 '슬링샷' 개발중…스냅챗 잡기"</h1>
 <p>보도에 따르면 마크 저커버그 최고경영자(CEO)는 지난해 스냅챗을 인수하려는 마음을 먹고 스냅챗 창업자 에번 스피겔 등과 접촉했으나 거절당한 이후 슬링샷 프로젝트를 출범시키고 최고 기밀로 관리하면서 진척 상황을 감독해 왔다.</p>
 <p>슬링샷은 사용자가 화면을 두어 차례만 두드리면 짧은 비디오 메시지를 보낼 수 있도록 설계돼 있다.</p>
</div>
</body>
</html>

 

 

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<div>

<!-- 큰 제목 -->
<h1>HTML Basic Tags</h1>

<!-- 작은 제목 -->
<h2>Heading Tags</h2>
<!-- 본문 내용 -->
<p>Any document starts with a heading. You can use different sizes for your headings. HTML also has six levels of headings, which use the elements &lt;h1&gt;, &lt;h2&gt;, &lt;h3&gt;, &lt;h4&gt;, &lt;h5&gt;, and &lt;h6&gt;. While displaying any heading, browser adds one line before and one line after that heading.</p>

<!-- 작은 제목 -->
<h2>Paragraph Tag</h2>
<!-- 본문 내용 -->
<p>The &lt;p&gt; tag offers a way to structure your text into different paragraphs. Each paragraph of text should go in between an opening &lt;p&gt; and a closing &lt;/p&gt; tag as shown below in the example:</p>

<!-- 작은 제목 -->
<h2>Line Break Tag</h2>
<!-- 본문 내용 -->
<p>Whenever you use the &lt;br /&gt; element, anything following it starts from the next line. This tag is an example of an empty element, where you do not need opening and closing tags, as there is nothing to go in between them.</p>
<p>The &lt;br /&gt; tag has a space between the characters br and the forward slash. If you omit this space, older browsers will have trouble rendering the line break, while if you miss the forward slash character and just use &lt;br&gt; it is not valid in XHTML</p>

</div>
</body>
</html>

 


----------------------------------------------
CSS (Cascading Style Sheets)

1. HTML 태그만으로는 표현 부분이 부족하기 때문에 CSS를 이용해서 출력 형태를 지정하게 된다.

2. CSS 기본 형식
"CSS 속성명 : 값" 형태의 명령을 특정 대상에 적용하면 지정된 속성에 따라 출력 형태가 달라진다.
예를 들어,  "color:red" 명령을 이용하면 특정 대상의 전경색이 빨간색으로 출력된다.

3. CSS 적용 방법
- 인라인 단위 적용 방법 : 특정 태그에만 적용되는 CSS. 웹페이지 내에서 특정 부분에만 적용하는 스타일 지정시 사용.
- 페이지 단위 적용 방법 : 특정 페이지에만 적용되는 CSS. 웹페이지 전체의 스타일 지정시 사용.
- 파일 단위 적용 방법 : 특정 파일 단위로 적용되는 CSS. 웹사이트 전체의 스타일 지정시 사용.

4. 인라인 단위 적용 방법
<태그명 style="CSS속성:값; CSS속성:값; ...">데이터</태그명>

5. 페이지 단위 적용 방법
<style type="text/css">
 선택자 { CSS속성:값; CSS속성:값; ... }
</style>
-> 선택자는 여러가지 표현에 의해 특정 태그를 찾는 명령이다. 한 개 이상의 태그를 동시에 찾을 수 있다.

6. 파일 단위 적용 방법
<link rel="stylesheet" type="text/css" href="파일명.css">
-> 별도의 .css 파일을 만들어서 그 안에 스타일 내용을 작성한다.


뉴스 페이지 작성 연습

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<style type="text/css">
/* 뉴스 기사에 대한 스타일 지정 추가 */

/* 선택자 {속성:값; .... } */
/* 선택자에 태그 이름을 사용하면 특정 태그 전체에 대해서 속성 적용된다. */
/* width 속성은 블럭 요소의 너비 지정 */
/* line-height 속성은 줄간격 지정 */
/* font-size 속성은 글자 크기 지정 */
/* color 속성은 전경색 지정 */
/* font-weight 속성은 글자 굵기 지정 */
/* margin-top, margin-bottom  속성은 여백 지정 */

div { width: 550px; line-height: 170%;}

h1 {font-size:18pt;}

h2 {font-size:12pt; color:#9B9C9A; font-weight: bold;}

p {font-size:10pt; margin-top:25px; margin-bottom:25px; }
</style>

</head>
<body>
<!-- 뉴스 기사 편집 테스트 -->
<div>

<!-- (큰)제목 태그 지정 -->
<h1>[프리미엄 리포트]“유명저널 게재 목표치 내라”… 창의성보다 숫자위주 평가</h1>

<!-- (중간)제목 태그 지정 -->
<h2>[3대 과학저널 한국인 논문 분석]과학자들이 말하는 문제점</h2>

<!-- 이미지(그림) 요소 지정 -->
<p><img src="http://imgnews.naver.net/image/020/2015/04/20/70793740.1_99_20150420040904.jpg?type=w540"></p>

<!-- 내용(문단) 태그 지정 -->
<p>우선 연구자 개인을 평가하는 데 피인용 지수에 대한 가중치를 너무 많이 둔다는 지적이 가장 많이 나왔다. 저널의 영향력을 나타내는 피인용 지수는 학술 정보 서비스 기업인 톰슨로이터가 만든 것으로 당초 도서관이 저널 구입 여부를 판단할 수 있도록 가이드라인을 제공할 목적으로 개발됐다.</p>

<!-- 내용(문단) 태그 지정 -->
<p>오세정 서울대 물리천문학부 교수는 “피인용 지수가 논문의 과학적 가치를 평가하는 잣대로 변질됐다”면서 “노벨 물리학상을 받은 연구자의 논문도 대부분 피인용 지수가 그다지 높지 않은 물리 전문 저널에 발표됐다”고 말했다. 지난해 청색 발광다이오드(LED)를 개발해 노벨 물리학상을 받은 논문은 피인용 지수가 1.057인 ‘일본 응용물리학저널’ 등에 발표됐다. 세계 3대 저널인 네이처, 사이언스, 셀의 피인용 지수는 30∼40 수준이다.</p>


</div>

</body>
</html>

--------------------------------------------
요약

1. 웹 어플리케이션의 특징
- 웹클라이언트와 웹서버의 역할
- 요청과 응답 메커니즘
- 브라우저(IE, FF, CR), 웹서버(Apache Tomcat)

2. 이클립스 환경설정
- Dynamic Web Project 생성
- 톰캣 서버 연동
- .html, .jsp 파일 생성

3. HTML 페이지 특성

4. CSS 특성

----------------------------------------------

 

'HTML/CSS' 카테고리의 다른 글

4일차_CSS  (0) 2015.06.21
3일차_HTML 태그의 종류, CSS  (0) 2015.06.21
2일차_HTML 태그의 종류  (1) 2015.06.21
09일차_거품정렬,선택정렬,삽입정렬  (0) 2015.06.21
블로그 이미지

알 수 없는 사용자

,

---------------------------------
정렬 알고리즘

1. 원소들을 번호순이나 사전 순서와 같이 일정한 순서대로 열거하는 알고리즘

2.
거품 정렬, 삽입 정렬, 선택 정렬....

3. 거품 정렬(bubble sort) : 두 인접한 원소를 검사하여 정렬하는 방법
55 07 78 12 42  -> 원본 상태

[55 07] 78 12 42  첫 번째 패스
07 [55 78] 12 42
07 55 [78 12] 42
07 55 12 [78 42]
07 55 12 42 [78]

[07 55] 12 42  - 78  두 번째 패스 (가장 오른쪽 값은 제외)
07 [55 12] 42  - 78
07 12 [55 42]  - 78
07 12 42 [55]  - 78

[07 12] 42  - 55 78  세 번째 패스 (오른쪽 값 두 개는 제외)
07 [12 42]  - 55 78
07 12 [42]  - 55 78

[07 12]  - 42 55 78  네 번째 패스 (오른쪽 값 세 개는 제외)
07 [12]  - 42 55 78

07 12 42 55 78 => 정렬 끝

 

문제) 거품 정렬 알고리즘
4 5 3 1 2

1회전 -> ? ? ? ? 5
2회전 -> ? ? ? 4 5
3회전 -> ? ? 3 4 5
4회전 -> ? 2 3 4 5
정렬 완료 -> 1 2 3 4 5

 


//Sample60.java
package com.test;

public class Sample60 {

 public static void main(String[] args) {

  int[] array = {4, 5, 3, 1, 2};
  
  //정렬 과정 추가
  //1. 비교 if(조건)
  //2. 치환  array[n] <= array[n+1];
  //3. 반복 for(초기식;조건식;증감식)
  
  //a->0부터 (n-2)까지
  //b->1부터 (n-1)까지->a+1
  /*
  if (array[0] > array[1]) {
   int temp = array[1];
   array[1] = array[0];
   array[0] = temp;
  }
  if (array[1] > array[2]) {
   int temp = array[2];
   array[2] = array[1];
   array[1] = temp;
  }
  if (array[2] > array[3]) {
   int temp = array[3];
   array[3] = array[2];
   array[2] = temp;
  }
  if (array[3] > array[4]) {
   int temp = array[4];
   array[4] = array[3];
   array[3] = temp;
  }
  */
  int n = array.length;
  for (int a=0; a<n-1; ++a) {
   if (array[a] > array[a+1]) {
    int temp = array[a+1];
    array[a+1] = array[a];
    array[a] = temp;
   }
  }
  
  for (int a=0; a<array.length; ++a) {
   System.out.printf(" %d", array[a]);
  }
  System.out.println();
  
 }

}

 

 


거품 정렬 구현 코드
//Sample61.java
package com.test;

public class Sample61 {

 public static void main(String[] args) {

  int[] array = {4, 5, 3, 1, 2};
  
  //정렬 과정 추가
  //1. 비교 if(조건)
  //2. 치환  array[n] <= array[n+1];
  //3. 반복 for(초기식;조건식;증감식)

  //n이 5인 경우 4회전, 10인 경우 9회전
  //n->length부터 2까지
  //a->0부터 (n-2)까지
  //b->1부터 (n-1)까지->a+1
  for (int n=array.length; n>=2; --n) {
   for (int a=0; a<n-1; ++a) {
    if (array[a] > array[a+1]) {
     int temp = array[a+1];
     array[a+1] = array[a];
     array[a] = temp;
    }
   }
  }
  
  for (int a=0; a<array.length; ++a) {
   System.out.printf(" %d", array[a]);
  }
  System.out.println();
  
 }

}

 

 


//Sample62.java
package com.test;

public class Sample62 {

 public static void main(String[] args) {

  int[] array = {4, 5, 6, 3, 7, 1, 2};
  
  //정렬 과정 추가
  //1. 비교 if(조건)
  //2. 치환  array[n] <= array[n+1];
  //3. 반복 for(초기식;조건식;증감식)

  //n이 5인 경우 4회전, 10인 경우 9회전
  //n->1부터 1씩 증가하도록 작성
  //a->0부터 (n-2)까지
  //b->1부터 (n-1)까지->a+1
  for (int n=1; n<array.length ;++n) {
   for (int a=0; a<array.length-n; ++a) {
    if (array[a] > array[a+1]) {
     int temp = array[a+1];
     array[a+1] = array[a];
     array[a] = temp;
    }
   }
  }
  
  for (int a=0; a<array.length; ++a) {
   System.out.printf(" %d", array[a]);
  }
  System.out.println();
  
 }

}

 


-------------------------------------------------


//Sample63.java
package com.test;

public class Sample63 {

 public static void main(String[] args) {

  int[] array = {4, 5, 3, 1, 2};
  
  //정렬 과정 추가
  //1. 비교 if(조건)
  //2. 치환  array[n] <= array[n+1];
  //3. 반복 for(초기식;조건식;증감식)

  //n이 5인 경우 4회전, 10인 경우 9회전
  //n->1부터 1씩 증가하도록 작성
  //a->0부터 (n-2)까지
  //b->1부터 (n-1)까지->a+1
  for (int n=1; n<array.length ;++n) {
   for (int a=0; a<array.length-n; ++a) {
    if (array[a] > array[a+1]) {
     int temp = array[a+1];
     array[a+1] = array[a];
     array[a] = temp;
    }
   }
   
   //중간 결과 출력
   for (int a=0; a<array.length; ++a) {
    if (a == array.length-n) {
     System.out.print(" <");
    }
    System.out.printf(" %d", array[a]);
   }
   System.out.println();   
  }

  //최종 결과 출력
  System.out.println("--------------------");
  for (int a=0; a<array.length; ++a) {
   System.out.printf(" %d", array[a]);
  }
  System.out.println();
  
 }

}

 


문제) 외부에서 여러개의 숫자를 입력 받은 후에, 정렬(거품정렬) 시켜서 출력.
입력 범위(2~n)?5
정수1?5
정수2?2
정수3?3
정수4?1
정수5?4

정렬 결과 : 1 2 3 4 5

 


---------------------------------------------------


4. 선택 정렬(selection sort) : 전체 리스트에서 최소값을 가장 앞에 위치시키는 정렬 방법. 비교는 가장 앞에 있는 값과 나머지 값들을 비교.
55 07 78 12 42  -> 원본 상태

[55] [07] 78 12 42 첫 번째 패스
[07] 55 [78] 12 42
[07] 55 78 [12] 42
[07] 55 78 12 [42]
[07] 55 78 12 42

07 - [55] [78] 12 42 두 번째 패스 (가장 왼쪽 값은 제외)
07 - [55] 78 [12] 42
07 - [12] 78 55 [42]
07 - [12] 78 55 42

07 12 - [78] [55] 42 세 번째 패스 (왼쪽 두 개는 제외)
07 12 - [55] 78 [42]
07 12 - [42] 78 55

07 12 42 - [78] [55] 네 번째 패스 (왼쪽 세 개는 제외)
07 12 42 - [55] 78

07 12 42 55 78 -> 정렬 결과

 


문제) 선택 정렬 알고리즘
4 5 3 1 2

1회전 -> 1 ? ? ? ?
2회전 -> 1 2 ? ? ?
3회전 -> 1 2 3 ? ?
4회전 -> 1 2 3 4 ?
정렬 완료 -> 1 2 3 4 5

 


//Sample64.java
package com.test;

public class Sample64 {

 public static void main(String[] args) {

  int[] array = {4, 5, 3, 1, 2};
  
  //정렬 과정 추가
  //1. 비교 if(조건)
  //2. 치환  array[n] <= array[n+1];
  //3. 반복 for(초기식;조건식;증감식)
  
  /*
  if (array[0] > array[1]) {
   int temp = array[1];
   array[1] = array[0];
   array[0] = temp;   
  }
  if (array[0] > array[2]) {
   int temp = array[2];
   array[2] = array[0];
   array[0] = temp;   
  }
  if (array[0] > array[3]) {
   int temp = array[3];
   array[3] = array[0];
   array[0] = temp;   
  }
  if (array[0] > array[4]) {
   int temp = array[4];
   array[4] = array[0];
   array[0] = temp;   
  }
  */
  
  //n => 갯수
  //a => 0
  //b => 1 ~ (n-1)
  int n=array.length;
  int a=0;
  for (int b=1; b<n; ++b) {
   if (array[a] > array[b]) {
    int temp = array[b];
    array[b] = array[a];
    array[a] = temp;   
   }
  }
  
  for (int c=0; c<array.length; ++c) {
   System.out.printf(" %d", array[c]);
  }
  System.out.println();  
  
 }

}

 

 

선택 정렬 구현 코드
//Sample65.java
package com.test;

public class Sample65 {

 public static void main(String[] args) {

  int[] array = {4, 5, 3, 1, 2};
  
  //정렬 과정 추가
  //1. 비교 if(조건)
  //2. 치환  array[n] <= array[n+1];
  //3. 반복 for(초기식;조건식;증감식)
  
  //n => 갯수(array.length)
  //a => 0 ~ (n-2)
  //b => (a+1) ~ (n-1)
  for (int a=0; a<array.length-1; ++a) {
   for (int b=(a+1); b<array.length; ++b) {
    if (array[a] > array[b]) {
     int temp = array[b];
     array[b] = array[a];
     array[a] = temp;   
    }
   }

   //중간 결과 출력
   for (int c=0; c<array.length; ++c) {
    if (c == (a+1)) {
     System.out.print(" <");
    }
    System.out.printf(" %d", array[c]);
   }
   System.out.println(); 


  }
  
  for (int c=0; c<array.length; ++c) {
   System.out.printf(" %d", array[c]);
  }
  System.out.println();  
  
 }

}

 

 

문제) 외부에서 여러개의 숫자를 입력 받은 후에, 정렬(선택정렬) 시켜서 출력.

입력 범위(2~n)?5
정수1?5
정수2?2
정수3?3
정수4?1
정수5?4

정렬 결과 : 1 2 3 4 5

 

 

 


-----------------------------------
삽입 정렬(insertion sort)

1. 자료 배열의 모든 요소를 앞에서부터 차례대로 이미 정렬된 배열 부분과 비교하여, 자신의 위치를 찾아 삽입함으로써 정렬을 완성하는 알고리즘

55 07 78 12 42  -> 원본 상태

55 (07) 78 12 42 -> key        첫 번째 패스
[55] 07 78 12 42 - [key=07]
55 [55] 78 12 42
[07] 55 78 12 42 <- [key=07]
[07] 55 78 12 42

07 55 (78) 12 42 -> key       두 번째 패스
07 [55] 78 12 42 - [key=78]
[07] 55 78 12 42 - [key=78]
07 55 [78] 12 42 <- [key=78]
07 55 [78] 12 42

07 55 78 (12) 42 -> key      세 번째 패스
07 55 [78] 12 42 - [key=12]
07 55 78 [78] 42
07 [55] 78 78 42 - [key=12]
07 55 [55] 78 42
[07] 55 55 78 42 - [key=12]
07 [12] 55 78 42 <- [key=12]
07 [12] 55 78 42

07 12 55 78 (42) -> key     네 번째 패스
문제) 선택 정렬의 네 번째 패스에서 나머지 숫자 배열을 채웁니다.

 


------------------------------------------
여러명의 점수를 입력 받고, 점수가 높은 순으로 등수 부여해서 출력하는 과정 작성. 이름과 점수는 별도의 배열에 저장.
실행 예)
입력 범위(2~n)?3
이름 점수(1)?kim 30
이름 점수(2)?choi 70
이름 점수(3)?park 60
---------------------
1등 choi 70
2등 park 60
3등 kim 30
---------------------

//Sample48.java
package com.test;

import java.util.Scanner;

public class Sample48 {
 
 public static void main(String[] args) {
  
  //여러명의 이름, 점수 입력 -> 배열 2개
  Scanner sc = new Scanner(System.in);
  System.out.print("인원수(n)?");
  int size = sc.nextInt();
  String[] names = new String[size];
  int[] scores = new int[size];
  
  for (int i=0; i<names.length; ++i) {
   System.out.printf("이름 점수(%d)?", (i+1));
   names[i] = sc.next();
   scores[i] = sc.nextInt();
  }
  sc.close();
  
  //점수가 높은 순으로 정렬 (내림차순)
  //n회전 반복
  //1회전 반복
  //비교대상
  //치환
  for (int b=0; b<scores.length-1; ++b) {
   for (int a=0; a<scores.length-1-b; ++a) {
    if (scores[a] < scores[a+1]) {
     String temp1 = names[a+1];
     names[a+1] = names[a];
     names[a] = temp1;
     int temp2 = scores[a+1];
     scores[a+1] = scores[a];
     scores[a] = temp2;
    }
   }
  }
  
  //배열->출력
  for (int b=0; b<scores.length; ++b) {
   System.out.printf("%d등 %s %d %n"
       , (b+1)
       , names[b]
       , scores[b]);
  }
  System.out.println();

 }

}

 

 

문제) 위의 결과에서 정렬 알고리즘을 선택 정렬로 수정할 것.
//Sample49.java
package com.test;

import java.util.Scanner;

public class Sample49{
 
 
 public static void main(String[] args) {
  
  //여러명의 이름, 점수 입력 -> 배열 2개
  Scanner sc = new Scanner(System.in);
  System.out.print("인원수(n)?");
  int size = sc.nextInt();
  String[] names = new String[size];
  int[] scores = new int[size];
  
  for (int i=0; i<names.length; ++i) {
   System.out.printf("이름 점수(%d)?", (i+1));
   names[i] = sc.next();
   scores[i] = sc.nextInt();
   
  }
  sc.close();
  
  //문제) 점수가 높은 순으로 정렬 (선택정렬, 내림차순)
  

 

  
  //배열->출력
  for (int b=0; b<scores.length; ++b) {
   System.out.printf("%d등 %s %d %n"
       , (b+1)
       , names[b]
       , scores[b]);
  }
  System.out.println();

 }

}

 

 

 


-------------------------------------------
과제) 삽입 정렬 순서도(삽입정렬_순서도.png)를 완성하고, Java 프로그램으로 작성.

 

 

 

 


-------------------------------------------
요약

1. 정렬 알고리즘
2. 거품 정렬 : 인접한 두 숫자 비교, 큰 값 오른쪽.
3. 선택 정렬 : 기준값과 나머지를 비교. 작은 값 왼쪽.
3. 삽입 정렬 : key 변수 필요. key 변수에 기준값 저장. key와 나머지 값과 비교. 자기 위치를 찾아서 삽입.

-------------------------------------------

 

 

 

 

 

 


 

'HTML/CSS' 카테고리의 다른 글

4일차_CSS  (0) 2015.06.21
3일차_HTML 태그의 종류, CSS  (0) 2015.06.21
2일차_HTML 태그의 종류  (1) 2015.06.21
1일차_웹어플리케이션개요, HTML개요, CSS개요.txt  (0) 2015.06.21
블로그 이미지

알 수 없는 사용자

,