비욘세
 (Beyonce Knowles | Beyonce Giselle Knowles) 가수,영화배우
1981년 9월 4일 (미국)
170cm
배우자 제이 지, 동생 솔란지 노울스
학력
공연시각예술고등학교
데뷔
1997년 데스티니스 차일드 1집 앨범 [Destiny's Child]
사이트
공식사이트


드림걸즈를 다시 보고 감동먹어서 올리는거...
용세가 왜일케 호소하듯 열창을 하는지는 드림걸즈를 보시길... ㅎㅎㅎㅎㅎㅎㅎㅎ

Listen,
들어줘요
to the song here in my heart
내 맘속에 담긴 이 노래를
A melody I start
첫 멜로디는 내가 시작했지만
But can´t complete
난 끝맺을수가 없어요

Listen,
들어줘요
to the sound from deep within
나의 내면속의 담긴 소리를
It´s only beginning
오직 시작일 뿐이죠
To find release
해방되기 위한

Oh, the time has come
오, 때가 오네요
for my dreams to be heard
내 꿈에 귀 기울여야 할때가
They will not be pushed aside
이제 내꿈은 무시되고
and turned Into your own
당신 것으로 바뀌지 않을거예요
all cause you won´t Listen
당신이 들으려하지 않으니까요

Listen,
들어줘요
I am alone at a crossroads
난 교차에 홀로 서있어요
I´m not at home, in my own home
난 집에 있지 않아요, 나만의 집에
And I´ve tried and tried
난 노력하고 노력했어요
To say whats on my mind
내 마음속에 있는 말을 하려고
You should have known
당신은 그걸 알았어야했어요


Oh, Now I´m done believin you
이제는 당신 그만 믿을래요
You don´t know what I´m feelin
당신은 내 기분을 몰라요
I´m more than what, you made of me
난 당신이 만들어 낸 존재가 아니예요
I followed the voice you gave to me
난 당신이 보낸 소릴 따라갔었죠
But now I gotta find, my own
하지만 이제 난 찾아야겠어요 나만의 소리를

You should have listened
당신을 귀 기울였어야했어요
There is someone here inside
여기 안에 있는 누군가의 소리를
Someone I´d thought had died So long ago
오래전에 죽어버렸던 그 사람의 소리를

Oh I´m free now and my dreams will be heard
그리고 내 꿈에 귀기울거예요
They will not be pushed aside onwards Into your own
당신것으로 바뀌지 않을꺼예요
All cause you won´t Listen
당신은 들으려 하지 않았으니까요

Listen,
들어줘요
I am alone at a crossroads
난 교차에 홀로 서있어요
I´m not at home, in my own home
난 집에 있지 않아요, 나만의 집에
And I´ve tried and tried
난 노력하고 노력했어요
To say whats on my mind
내 마음속에 있는 말을 하려고
You should have known
당신은 그걸 알았어야했어요


Oh, now I'm done believin you
이제는 당신 그만 믿을래요
You don´t know what I´m feelin
당신은 내 기분을 몰라요
I´m more than what, you made of me
난 당신이 만들어 낸 존재가 아니예요
I followed the voice you gave to me
난 당신이 보낸 소릴 따라갔었죠
But now I gotta find, my own
하지만 이제 난 찾아야겠어요 나만의 소리를

I don´t know where I belong
내가 어디에 속하는지 몰라요
But I´ll be movin on
하지만 난 그럴꺼예요
If you don´t
만약 당신이
If you won´t
당신이 만약

LISTEN
듣지 않는다면요
to the song here in my heart
내 마음속에 있는 이 노래를
A melody I´ve start
내가 시작한 이 멜로디지만
But I will complete
내가 끝맺을 거예요 


Oh, now I'm done believin you
이제 당신 그만 믿을래요
You don´t know what I´m feelin
당신은 내 기분이 어떤지 몰라요
I´m more than what, you made of me
난 당신이 만들어 낸 나, 그 이상이예요
I followed the voice, you think you gave to me
당신이 내게 보냇단 그 소리를 따라왔었죠
But now I gotta find, my own
이제 난 찾아야겟어요. 나만의
my own
나만의 소리를

dROdk2SLJkIZdlElPLLNgwfHUf3fmvh_QR77SODdIkk,


THE 4TH ALBUM ; 4MEN - 살다가 한번쯤

눈을 감기만 해도 눈물이 흘러 니가 보여서 많이 보고싶어서
I know 다 끝난 일인걸

같은 공간 같은 시간 같은 세상이지만
어딜 봐도 어딜 가도 너는 보이질 않아

살다가 한번쯤은 마주치기를 난 아직도 그곳에 살아
어디서 그 어디서 무얼하든지 건강하게 행복하게 살아

살아있단 것으로 정말 고마워 너의 소식이 내가 사는 이윤걸
I know 다 끝난 일인걸

다른 만남 다른 사람 사랑해도 괜찮아
누굴 만나 뭐가 됐건 너만 행복하면 되

살다가 한번쯤은 마주치기를 난 아직도 그곳에 살아
어디서 그 어디서 무얼하든지 건강하게 행복하게 살아

한번만 딱 한번만 마주친다면 꼭 이 말 전해줄거야
태어나 너를 만나 고마웠다고
잘살라고 꼭 행복하라고

 



Lesson 1: The basics of C++

This tutorial series is designed for everyone: even if you've never programmed before or if you have extensive experience programming in other languages and want to expand into C++! It is for everyone who wants the feeling of accomplishment from a working program. 

What do I mean? C++ is a programming language--it will allow you to control your computer, making it do what you want it to do. This programming tutorial series is all about helping you take advantage of C++.
The very first thing you need to do, before starting out in C++, is to make sure that you have a compiler. What is a compiler, you ask? A compiler turns the program that you write into an executable that your computer can actually understand and run. If you're taking a course, you probably have one provided through your school. If you're starting out on your own, your best bet is to use Code::Blocks. Our page on setting up Code::Blocks will take you through setting up the Code::Blocks compiler in great detail.

Advanced Compiler Details

If you've got some prior experience, or just want a menu of choices, you should know that there are several common compilers. If you're new to programming, just skip this section! 

Some common compilers include Borland C++Microsoft C++, and GNU C++

There are also many front-end environments for the different compilers--the most common is Dev-C++ around GNU's G++ compiler. Some, such as G++, are free, while others are not. Please see the compiler listing for more information on how to get a compiler and set it up. 

Each of these compilers is slightly different. Each one should support the ANSI/ISO standard C++ functions, but each compiler will also have nonstandard functions (these functions are similar to slang spoken in different parts of a country). Sometimes the use of nonstandard functions will cause problems when you attempt to compile source code (the actual C++ written by a programmer and saved as a text file) with a different compiler. These tutorials use ANSI/ISO standard C++ and should not suffer from this problem (with sufficiently modern compilers). Note that if you are using an older compiler, such as TCLite, you should read check out some compatibility issues

Intro to the C++ Language

A C++ program is a collection of commands, which tell the computer to do "something". This collection of commands is usually called C++ source codesource code or just code. Commands are either "functions" or "keywords". Keywords are a basic building block of the language, while functions are, in fact, usually written in terms of simpler functions--you'll see this in our very first program, below. (Confused? Think of it a bit like an outline for a book; the outline might show every chapter in the book; each chapter might have its own outline, composed of sections. Each section might have its own outline, or it might have all of the details written up.) Thankfully, C++ provides a great many common functions and keywords that you can use. 

But how does a program actually start? Every program in C++ has one function, always named main, that is always called when your program first executes. From main, you can also call other functions whether they are written by us or, as mentioned earlier, provided by the compiler. 

So how do you get access to those prewritten functions? To access those standard functions that comes with the compiler, you include a header with the #include directive. What this does is effectively take everything in the header and paste it into your program. Let's look at a working program:
 
#include <iostream>

using namespace std;

int main()
{
  cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
  cin.get();
}
Let's look at the elements of the program. The #include is a "preprocessor" directive that tells the compiler to put code from the header called iostream into our program before actually creating the executable. By including header files, you gain access to many different functions. For example, the cout function requires iostream. Following the include is the statement, "using namespace std;". This line tells the compiler to use a group of functions that are part of the standard library (std). By including this line at the top of a file, you allow the program to use functions such as cout. The semicolon is part of the syntax of C++. It tells the compiler that you're at the end of a command. You will see later that the semicolon is used to end most commands in C++. 

The next important line is int main(). This line tells the compiler that there is a function named main, and that the function returns an integer, hence int. The "curly braces" ({ and }) signal the beginning and end of functions and other code blocks. You can think of them as meaning BEGIN and END. 

The next line of the program may seem strange. If you have programmed in another language, you might expect that print would be the function used to display text. In C++, however, the cout object is used to display text (pronounced "C out"). It uses the << symbols, known as "insertion operators", to indicate what to output. cout<< results in a function call with the ensuing text as an argument to the function. The quotes tell the compiler that you want to output the literal string as-is. The '\n' sequence is actually treated as a single character that stands for a newline (we'll talk about this later in more detail). It moves the cursor on your screen to the next line. Again, notice the semicolon: it is added onto the end of most lines, such as function calls, in C++. 

The next command is cin.get(). This is another function call: it reads in input and expects the user to hit the return key. Many compiler environments will open a new console window, run the program, and then close the window. This command keeps that window from closing because the program is not done yet because it waits for you to hit enter. Including that line gives you time to see the program run. 

Upon reaching the end of main, the closing brace, our program will return the value of 0 (and integer, hence why we told main to return an int) to the operating system. This return value is important as it can be used to tell the OS whether our program succeeded or not. A return value of 0 means success and is returned automatically (but only for main, other functions require you to manually return a value), but if we wanted to return something else, such as 1, we would have to do it with a return statement:
 
#include <iostream>

using namespace std;

int main()
{
  cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
  cin.get();

  return 1;
}
The final brace closes off the function. You should try compiling this program and running it. You can cut and paste the code into a file, save it as a .cpp file. Our Code::Blocks tutorial actually takes you through creating a simple program, so check it out if you're confused. 

If you are not using Code::Blocks, you should read the compiler instructions for information on how to compile. 
Once you've got your first program running, why don't you try playing around with the cout function to get used to writing C++?

An Aside on Commenting Your Programs

As you are learning to program, you should also start to learn how to explain your programs (for yourself, if no one else). You do this by adding comments to code; I'll use them frequently to help explain code examples. 

When you tell the compiler a section of text is a comment, it will ignore it when running the code, allowing you to use any text you want to describe the real code. To create a comment use either //, which tells the compiler that the rest of the line is a comment, or /* and then */ to block off everything between as a comment. Certain compiler environments will change the color of a commented area, but some will not. Be certain not to accidentally comment out code (that is, to tell the compiler part of your code is a comment) you need for the program. When you are learning to program, it is useful to be able to comment out sections of code in order to see how the output is affected. 

User interaction and Saving Information with Variables

So far you've learned how to write a simple program to display information typed in by you, the programmer, and how to describe your program with comments. That's great, but what about interacting with your user? Fortunately, it is also possible for your program to accept input. The function you use is known as cin, and is followed by the insertion operator >>. 

Of course, before you try to receive input, you must have a place to store that input. In programming, input and data are stored in variables. There are several different types of variables which store different kinds of information (e.g. numbers versus letters); when you tell the compiler you are declaring a variable, you must include the data type along with the name of the variable. Several basic types include char, int, and float. 

A variable of type char stores a single character, variables of type int store integers (numbers without decimal places), and variables of type float store numbers with decimal places. Each of these variable types - char, int, and float - is each a keyword that you use when you declare a variable.

What's with all these variable types?

Sometimes it can be confusing to have multiple variable types when it seems like some variable types are redundant (why have integer numbers when you have floats?). Using the right variable type can be important for making your code readable and for efficiency--some variables require more memory than others. Moreover, because of the way the numbers are actually stored in memory, a float is "inexact", and should not be used when you need to store an "exact" integer value. 

Declaring Variables in C++

To declare a variable you use the syntax "type <name>;". Here are some variable declaration examples:
 
int x;
char letter;
float the_float;
It is permissible to declare multiple variables of the same type on the same line; each one should be separated by a comma.
int a, b, c, d;
If you were watching closely, you might have seen that declaration of a variable is always followed by a semicolon (note that this is the same procedure used when you call a function).

Common Errors when Declaring Variables in C++

If you attempt to use a variable that you have not declared, your program will not be compiled or run, and you will receive an error message informing you that you have made a mistake. Usually, this is called an undeclared variable.

Case Sensitivity

Now is a good time to talk about an important concept that can easily throw you off: case sensitivity. Basically, in C++, whether you use uppercase or lowercase letters matters. The words Cat and cat mean different things to the compiler. In C++, all language keywords, all functions and all variables are case sensitive. A difference in case between your variable declaration and the use of the variable is one reason you might get an undeclared variable error.

Using Variables

Ok, so you now know how to tell the compiler about variables, but what about using them? 

Here is a sample program demonstrating the use of a variable:
 
#include <iostream>

using namespace std;

int main()
{
  int thisisanumber;

  cout<<"Please enter a number: ";
  cin>> thisisanumber;
  cin.ignore();
  cout<<"You entered: "<< thisisanumber <<"\n";
  cin.get();
}
Let's break apart this program and examine it line by line. The keyword int declares thisisanumber to be an integer. The function cin>> reads a value into thisisanumber; the user must press enter before the number is read by the program. cin.ignore() is another function that reads and discards a character. Remember that when you type input into a program, it takes the enter key too. We don't need this, so we throw it away. Keep in mind that the variable was declared an integer; if the user attempts to type in a decimal number, it will be truncated (that is, the decimal component of the number will be ignored). Try typing in a sequence of characters or a decimal number when you run the example program; the response will vary from input to input, but in no case is it particularly pretty. Notice that when printing out a variable quotation marks are not used. Were there quotation marks, the output would be "You Entered: thisisanumber." The lack of quotation marks informs the compiler that there is a variable, and therefore that the program should check the value of the variable in order to replace the variable name with the variable when executing the output function. Do not be confused by the inclusion of two separate insertion operators on one line. Including multiple insertion operators on one line is perfectly acceptable and all of the output will go to the same place. In fact, you must separate string literals (strings enclosed in quotation marks) and variables by giving each its own insertion operators (<<). Trying to put two variables together with only one << will give you an error message, do not try it. Do not forget to end functions and declarations with a semicolon. If you forget the semicolon, the compiler will give you an error message when you attempt to compile the program.

Changing and Comparing Variables

Of course, no matter what type you use, variables are uninteresting without the ability to modify them. Several operators used with variables include the following: *, -, +, /, =, ==, >, <. The * multiplies, the - subtracts, and the + adds. It is of course important to realize that to modify the value of a variable inside the program it is rather important to use the equal sign. In some languages, the equal sign compares the value of the left and right values, but in C++ == is used for that task. The equal sign is still extremely useful. It sets the left input to the equal sign, which must be one, and only one, variable equal to the value on the right side of the equal sign. The operators that perform mathematical functions should be used on the right side of an equal sign in order to assign the result to a variable on the left side. 

Here are a few examples:
 
a = 4 * 6; // (Note use of comments and of semicolon) a is 24
a = a + 5; // a equals the original value of a with five added to it
a == 5     // Does NOT assign five to a. Rather, it checks to see if a equals 5.
The other form of equal, ==, is not a way to assign a value to a variable. Rather, it checks to see if the variables are equal. It is useful in other areas of C++; for example, you will often use == in such constructions as conditional statements and loops. You can probably guess how < and > function. They are greater than and less than operators. 

For example:
 
a < 5  // Checks to see if a is less than five
a > 5  // Checks to see if a is greater than five
a == 5 // Checks to see if a equals five, for good measure 
Comparing variables isn't really useful until you have some way of using the results--that's what lesson 2, on if statements is all about. 

'프로그래밍 > C, C++' 카테고리의 다른 글

구구단 출력 소스 C  (0) 2011.06.07
8진수, 16진수의 이해  (0) 2011.06.07
2진 트리 검색  (0) 2011.06.07
The C Preprocessor  (0) 2011.06.07
The C++ Modulus Operator  (0) 2011.06.07

Fedora, Red Hat, Centos와 설치방법은 같습니다.
ClearOS

Last Update: Monday 6 June 2011 13:12 GMT
  • Based on: Fedora, Red Hat
  • Origin: Canada 
  • Architecture: i386, x86_64
  • Desktop: GNOME, KDE
  • Category: Desktop, Firewall, Security,Server

 Downloadclearos-core-6.1alpha1-x86_64.iso (3,616MB, SHA256torrent).

ClearOS Summary
Distribution ClearOS (formerly ClarkConnect)
Home Page http://www.clearfoundation.com/
Mailing Lists --
User Forums http://www.clearfoundation.com/component/option,com_kunena/Itemid,232/
Documentation http://www.clearfoundation.com/docs/
Screenshots http://www.clearfoundation.com/Software/screenshots.html
Download Mirrors http://www.clearfoundation.com/Software/downloads
Bug Tracker http://www.clearfoundation.com/docs/web_site/reporting_bugs
Related Web Sites ClearCenter • Wikipedia
Reviews 5.x: The Register • Linux Magazine • ITworld
3.x: Linux Blog
Where To Buy LinuxCD.org • OSDisc.com (sponsored links)

우선설치 ㅎ

fedora 나 Centos ,red hat을 설치해보신분이라면 아주 익숙하실껍니다.

Skip으로 걍 넘어갑니다. 이미지파일 무결성검사.. 오래걸립니다..

설치될언어 영어나 한국어 그외.. 선택해줍니다.

yes선택해줍니다.

설치될 국가별 시간대 서울,

Root사용자 비번.

VMware에서설치시 아무거나 선택해도 무방합니다.

기록

설치될 파일들 선택가능합니다. 
맨아래 
지금 선택 - 체크후 용도에 맞게 파일들 골라줍니다.

현제 시간을 네트워크를 통해 동기화 선택해줍니다.

메모리 부족하다고 메세지가 뜹니다. 무시 하면됩니다. 어차피 사용안할꺼니까요



Package6.1-alpha1 5.2
abiword (2.8.6)-- --
alsa-lib (1.0.24.1)1.0.21 1.0.17
amarok (2.4.1)-- --
ati-driver (8.850)-- --
bash (4.2)4.1 3.2
bind (9.8.0-P2)9.7.3 --
chromium (r88003)-- --
compiz (0.8.8)0.8.2 --
cups (1.4.6)1.4.2 1.3.7
db (5.1.25)4.7.25 4.3.29
dhcp (4.2.1-P1)4.1.1-P1 3.0.5
emacs (23.3)23.1 --
firefox (4.0.1)3.6.17 --
freetype (2.4.4)2.3.11 2.2.1
gcc (4.6.0)4.4.5 --
gimp (2.6.11)2.6.9 --
glibc (2.14)2.12 2.5
gnucash (2.4.6)-- --
gnumeric (1.10.15)-- --
grub (1.99)0.97 0.95
gtk+ (3.0.10)2.18.9 --
hal (0.5.14)0.5.14 0.5.8.1
httpd (2.2.19)2.2.15 2.2.3
inkscape (0.48.1)0.47 --
jre (6u25)-- --
k3b (2.0.2)1.0.5 --


Package6.1-alpha1 5.2
kdebase (4.6.3)4.3.4 --
libgnome (2.32.1)2.28.0 --
linux (2.6.39.1)2.6.32 2.6.18
module-init-tools (3.16)3.9 3.3-pre3
mono (2.10.2)-- --
mysql (5.5.13)5.1.52 5.0.77
nautilus (3.0.2)2.28.4 --
NVIDIA (270.41.19)-- --
OpenOffice.org (3.3.0)-- --
openssh (5.8p2)5.3p1 4.3p2
openssl (1.0.0d)1.0.0 0.9.8e
perl (5.14.0)5.10.1 5.8.8
php (5.3.6)5.3.3 5.1.6
pidgin (2.7.11)-- --
postfix (2.8.3)2.6.6 2.5.1
postgresql (9.0.4)8.4.7 --
Python (3.2)2.6.6 2.4.3
qt-x11 (4.7.3)4.6.2 --
samba (3.5.8)3.5.6 3.5.2
sendmail (8.14.5)8.14.4 --
thunderbird (3.1.10)-- --
udev (171)147 095
vim (7.3)7.2 7.0
xfce (4.8)-- --
xine-lib (1.1.19)-- --
xorg-server (1.10.2)1.7.7 --
 

** CTable. Version 1.0.
*/
/*NOTE: Minor Changes have been made to enable this program to run under TClite
Credit goes to David van Leerdam
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>

#define NAMELEN 11
#define MAX 10
#define MIN 1

char name[NAMELEN];
short int number,wrong;
int table,answer,ch;
int checktable(int table);

int checktable(int table);
void cap(char *ptr2name);


int main(void)
{
printf("\nCTable by David van Leerdam\n");
printf("Please enter your name (max. %d): ",NAMELEN-1);
gets(name);
cap(name);
printf("\nDo you want to practise some tables? (Y/N) ",name);
ch = toupper((int)getch());

if (ch == 'N') {
printf("\nOkidoki %s, but you'll have to do extra tomorrow!\n",name);
exit(EXIT_SUCCESS); }

else

do {
wrong=0;
printf("\nWhich table? ");
scanf("%d",&table);
checktable(table);
  number = MIN;

// hier worden de tafelsommen gemaakt
// en gecontroleerd.

do {
printf("%d x %d = ",number,table);
scanf("%d",&answer);
if (answer != (number*table))
{
printf("WRONG! %d x %d = %d!\n",number,table,number*table);
wrong++;
}

// beoordeling.

} while (number++ != (MAX));
switch(wrong) {
case 0: printf("\n%s: I'm proud of you! No wrong answer found practising table of %d!",name,table); break;
case 1:
case 2: printf("\n%s: Good work! You gave only %d wrong answers doing table of %d.",name,wrong,table); break;
case 3:
case 4: printf("\n%s: Can't you do a lot better? %d wrong anwers found doing table of %d.",name,wrong,table); break;
default : printf("\n%s: Practise a little more. You gave %d wrong answers doing table %d.",name,wrong,table); }
printf("\nDo you want to practice again? (Y/N) ");
ch = toupper((int)getch());
printf("\n");
} while (ch != 'N');
printf("\nCTable version 1.0. Copyright by David van Leerdam.\n");
}

// hier wordt gecontroleerd of het tafelnr. een heel getal is.
int checktable(int table)
{
if ((table < 0) || (table == '\n')) {
fprintf(stderr,"\nERROR: Input has to be a valid positive integer.\n");
exit(EXIT_FAILURE); }
   return 1;
      }

// verander de eerste letter van de naam in een hoofdletter.

void cap(char *ptr2name)
{
if(ptr2name[0])
*ptr2name = toupper((int)*ptr2name);
}

'프로그래밍 > C, C++' 카테고리의 다른 글

레슨 1: The basics of C++ ( C++ 의 기본 )  (0) 2011.06.07
8진수, 16진수의 이해  (0) 2011.06.07
2진 트리 검색  (0) 2011.06.07
The C Preprocessor  (0) 2011.06.07
The C++ Modulus Operator  (0) 2011.06.07

Understanding Different Base Systems

This essay is targeted at new students of computer programming or computer science who want to understand how base two (binary), base eight (octal), and base sixteen (hexadecimal) work. 

First of all, it's important to realize that each of these base systems is just another way of writing down the same number. When you convert a number between different bases, it should still have the same value. In this essay, when I want to refer to the actual value of a number (regardless of its base), I'll do it in base 10 because that's what most people are used to. 

It's generally easiest to understand the concept of different bases by looking at base 10. When we have a number in base 10, each digit can be referred to as the ones digit, tens digit, the hundreds digit, the thousands digit, or so forth. For instance, in the number 432, 4 is the hundreds digit, 3 is the tens digit, and 2 is the ones digit. 

Another way to think about this is to rewrite 432 as
  4 x 102 + 3 x 101+ 2 x 100
Each digit is multiplied by the next power of ten. Numbers in other bases, such as base 16, are merely numbers where the base is not ten! For instance, we could interpret 432 as though it were in base 16 by evaluating it as
  4 x 162 + 3 x 161+ 2 x 100
This would be the same as the number 1074 in base 10. 

So to convert a number from a given base into base 10, all we need to do is treat each place as a power of the given base times the value of the digit in that place. Note that customarily for a given base, only digits from 0 to the base minus one are used. For instance, in decimal, we only use the digits 0 through 9. That's because we don't need any more digits to express every possible number. (But we do need at least that many; if we only had 8 digits, how would we ever express the value 9?) 

Now, bases greater than 10 will require more than 10 possible digits. For intsance, the number 11 in base ten can be expressed in base 16 with only a single digit because the ones place in base 16 can range from 0 to 15. Since we only have 10 digits, the letters A through F are used to stand for the "digits" 10 through 15. So, for instance, the hexadecimal number B stands for the decimal number 11. 

Bases less than ten will require fewer digits--for instance, binary, which works using powers of two, only needs two digits: one and zero. The binary number 1001, for instance, is the same as writing
 1 * 231 * 221 * 211 * 20
which comes out to the decimal value 9. 

Numbers written in octal use a base of 8 instead of 2 or 16. See if you can figure out what the number 20 written in octal would be in base ten. 

Because octal, hexadecimal, and decimal numbers can often share the same digits, there needs to be some way of distinguishing between them. Traditionally, octal numbers are written with a leading 0; for instance, 020 is the same thing as the number 20 in base 8. Hexadecimal numbers are written with the prefix of "0x". So 0x20 would be the number 20 in base 16; we'd interpret it the same as the decimal number 32.

Converting from decimal to octal or hexadecimal

It turns out that when you wish to convert from decimal to octal or hexadecimal, there is a very easy formula that you can use. I'll give you the one for octal, and let you puzzle out the hexadecimal version (which may come quite naturally to some of you). 

To convert from octal to hexadecimal, all you need to do is group the binary digits into pairs of three and convert each one into the corresponding octal number. For instance, given the binary number 010011110, you would group 011 and 110 together. 010 is 2, 011 is 3 and 110 is 6. So the octal number is 0236. 

So why exactly does this work? Well, let's take a look at what 011110 looks like:
   0 * 28  1 * 27  0 * 26  0 * 25+ 1 * 24+ 1 * 23+ 1 * 22+ 1 * 21+ 0 * 20
That's actually the same as
   0 * 22 * 26+ 1 * 21 * 26+ 0 * 20 * 26+ 0 * 22 * 23+ 1 * 21 * 23+ 1 * 20 * 23+ 1 * 22 * 20+ 1 * 21 * 20+ 0 * 20 * 20
Whoa! First, notice that the far right column is actually turning into powers of 8! 23 is 8, and 26 is 64! So this means for each group of three digits, we have the base increasing by a factor of 8. Moreover, look at the right hand column. It can sum up to at most 7 (since 20 + 21 + 22 = 1 + 2 + 4 and the binary digit just decides whether each power of two is included into the sum or not). That's exactly the same as having eight digits, 0 through 7, and once we sum them all together, we multiply the sum by a power of eight. That's just the same as making each group of three binary digits an octal digit! 

Knowing this, can you come up with the way to do the same thing for hexadecimal numbers? 

'프로그래밍 > C, C++' 카테고리의 다른 글

레슨 1: The basics of C++ ( C++ 의 기본 )  (0) 2011.06.07
구구단 출력 소스 C  (0) 2011.06.07
2진 트리 검색  (0) 2011.06.07
The C Preprocessor  (0) 2011.06.07
The C++ Modulus Operator  (0) 2011.06.07

Binary Search Trees
Binary search trees (also known as just binary trees) are ordered trees in which all nodes have no more than two children. The parent node is always greater than all of the data in the left sub-tree that extends from the left child node, and the parent node is less than all of the data in the right sub-tree that extends from the right child node.

Here is the basic framwork for the binary search tree:

class binTree {
  public:
    binTree(void);         // Constructor
    ~binTree(void);        // Destructor

    void add(int item);    // Add function
    void remove(int item); // Remove function
    bool search(int item); // Search function
    void print(void);      // Print function
  
  private:
    binTreeNode *root;     // Root pointer

    // ...
    // The extra functions needed for implementation are put here
};

class binTreeNode {
  public:
    int data;                 // Actual data
    binTreeNode *left_child;  // Left child pointer
    binTreeNode *right_child; // Right child pointer
};

This code is very similar to the code of the linked list, but the node here is differs from the node to the linked list in that thisbinTreeNode points to two other nodes instead of just one.

Since the left child is always less than the parent and the right child is greater than the parent, the tree can easily print an ordered list of all of the elements with the following algorithm, also known as in-order traversal:

void printTree(binTreeNode *node) {
  printTree(node->left_child);  // Left child first
  cout << node->data << endl;   // Then this node
  printTree(node->right_child); // Then right child
}

To print the tree, you would call the function with the value of root. Each time, the function would keep calling itself (recursion!) until it reaches the leftmost node, which is the least value in the entire tree. Then, it would cycle through the entire tree, and then the right children, until it reaches the rightmost, or greatest, value in the tree.

Other traversals of trees are pre-order and post-order traversals. In pre-order, the root is processed first, then the left children, and then the right children. In post-order, the left children and right children are processed before the root.

Try writing the code for the binary tree as an exercise. It's a little tricky this time, especially with the remove() function. (HINT: Most of the functions require helper, or auxiliary, functions. Some, but definitely not all, of the functions may be recursive.)

'프로그래밍 > C, C++' 카테고리의 다른 글

구구단 출력 소스 C  (0) 2011.06.07
8진수, 16진수의 이해  (0) 2011.06.07
The C Preprocessor  (0) 2011.06.07
The C++ Modulus Operator  (0) 2011.06.07
Getting Random Values in C and C++ with Rand  (0) 2011.06.07

+ Recent posts