BLOG ARTICLE DEVELOP | 84 ARTICLE FOUND

  1. 2006.07.04 06/07/04 수업내용
  2. 2006.07.03 06/07/03 수업내용
  3. 2006.07.01 06/06/30 추가숙제
  4. 2006.07.01 06/07/03 숙제
  5. 2006.06.30 06/06/30 숙제
  6. 2006.06.30 06/06/30 수업내용
  7. 2006.06.29 06/06/29 수업내용
  8. 2006.06.29 이름/나이/몸무게
  9. 2006.06.28 2진수형식표현/구구단

06/07/04 수업내용

DEVELOP/C 2006. 7. 4. 15:17
1010  /  A  /  10
1011  /  B  /  11

1100  /  C  /  12
1101  /  D  /  13

1110  /  E  /  14
1111  /  F  /  15


*000 0000 0000 0000 0000 0000 0000 000# //32bit 2^8=256가지
* = MSB(Most Significant Bit)
# = LSB(Least Significant Bit)

2^3  /  8가지
2^4  /  16가지
2^5  /  32가지
2^6  /  64가지
2^7  /  128가지
2^8  /  256가지
......
2^16  /  65536가지
......
2^32  /  4294967296가지

modular operation
1111 + 1 = (1)0000



0에대한 1의보수 1    +1
1에대한 1의보수 0    +1

0에대한 2의보수 10
1에대한 2의보수 1

1의 보수
  0101
+1010
------
1111

2의 보수
  0101  //5
+1011  //-5
------
0000

0000 0000 0000 0000 0000 0000 0000 1010 //10
1111 1111 1111 1111 1111 1111 1111 0101 + 1
1111 1111 1111 1111 1111 1111 1111 0110 //-10 ??

0000 0000 0000 0000 0110 1001 0000 0000 //??
1111 1111 1111 1111 1001 0110 1111 1111 + 1
1111 1111 1111 1111 1001 0111 0000 0000 //-??
//가장 마지막 에 나오는 0을 1로 바꾸고 그이후의 1은 0으로 바꿈!!!!

4칸으로
-8~0~7(~15)까지 저장가능

signed int a=-1;
unsigned int b=255;

char ch=-1;
printf("%d",ch);
signed  /  %u  /  4294967295
unsigned  /  %u  /  255

____ ____ ____ ____ ____ ____  1111 1111  //char
1111 1111 1111 1111 1111 1111 1111 1111  //singned
0000 0000 0000 0000 0000 0000  1111 1111  //unsigned(바뀌었나??)
//확장시 주의!!!
//입력시는 문제없음!!!



double db=6.5;
6.5 -> 110.1 -> 1.101x2^2(normalization:정규화된 표현법)
정규화의 장점
1.부호 : +
2.지수 : 2
3.유효숫자 : 1101

IEEE
single : 4자리
double : 8
quad : 16

____ ____ ____ ____ ____ ____ ____ ____
0___ ____ ____ ____ ____ ____ ____ ____  //부호 1비트 63
_100 0000 0000 ____ ____ ____ ____ ____  //지수 11비트 62~52
____ ____ ____ 1010 00.......................0 //유효숫자 나머지.. 51~0
//2진수를 지수로 표현시 맨 앞자리는 1이므로 1을 제외한 유효숫자를 기입
1101 -> _101

2^53=10^x
x=약15
까지 저장가능

그에반해
1234568901234567890은 정확히 처리곤란
유효숫자가 더 많기 때문에

0.1234567890123456789
%lf  // 소수점6째자리까지..(기본)
%.30lf  // 소수점 30째자리까지
AND

06/07/03 수업내용

DEVELOP/C 2006. 7. 3. 14:33

숫자
  정수
  실수
문자
문자열

printf("%d",12)
        %x
        %o

printf("%d",12);
        %d,014  //8진수
        %d,0xc  //16진수

0.0000145=0.145x10^-4=-.145e-4  //표기~!!!


자동형변형
10/4.0
정수/실수->실수/실수=>실수

int main()
{
  int a,b;
  printf("두개의 정수를 입력:");
  scanf("%d%d",&a,&b);
  res=a/b;
  printf("a를 b로 나눈 값은 %lf\n",res);
  return 0;
}


형변환 연산자
res=a/b;
=>res=a/(double)b;
실수로 변환되어 연산..


#include <stdio.h>

int main()
{
int m_sal, ex_sal;
double taxrate, m_tax, t_sal, i_sal;

printf("본봉, 보너스, 세금을 입력하시오");
scanf("%d%d%lf",&m_sal,&ex_sal,&taxrate);

t_sal=m_sal+ex_sal;
// printf("%f",t_sal);
m_tax=t_sal*taxrate;
// printf("%f",m_tax);
i_sal=t_sal-m_tax;
printf("%lf",i_sal);
return 0;
}






#include <stdio.h>

int main()
{
int korean,english,mathm,t_score;//국 영 수
double avg_score;

printf("국어 영어 수학");
scanf("%d%d%d",&korean,&english,&mathm);

t_score=korean+english+mathm;
avg_score=(double)t_score/3.0;

printf("%d\t%d\t%d\n",korean,english,mathm);
printf("%d\t%lf",t_score,avg_score);
return 0;
}




연산자
+  -  *  /  %
10/3=3
10%3=1
10%3.0=??  //error,정수형만 나머지가 존재하므로




#include <stdio.h>

int main()
{

int input,fee,temp,charge,coin500,coin100,coin50,coin10;//입력금액,요금,거스름돈,동전별 개수
int c500,c100,c50,c10;//각동전별 현 보유개수

printf("현재 남은 동전 개수를 넣으시오. 500, 100, 50, 10");
scanf("%d%d%d%d",&c500,&c100,&c50,&c10); //입력받기
input=0;
while(1)//자판기에 투입한 돈 체크
{
printf("돈입력받기");
scanf("%d",&temp);
//  printf("%d\t",temp);

if (temp==0) break;
input=input+temp;
//  printf("%d\t",input);
temp=0;
}
printf("물건값은?");//고른물건 값 체크
scanf("%d",&fee);
printf("%d\t%d\n",input,fee);

charge=input-fee;//거스름돈 계산
coin500=charge/500;
if (coin500>=c500) coin500=c500;
coin100=(charge-(coin500*500))/100;
if (coin100>=c100) coin100=c100;
coin50=(charge-(coin500*500)-(coin100*100))/50;
if (coin50>=c50) coin50=c50;
coin10=(charge-(coin500*500)-(coin100*100)-(coin50*50))/10;
if (coin10>=c10)
printf("돈없다"); //불가

printf("500:%d\t100:%d\t50:%d\t10:%d\t총액:%d",coin500,coin100,coin50,coin10,charge);

}




#include <stdio.h>

int main()
{
int i=0;
while(i<72)
{
printf("%2dx%2d=%2d\t",i/9+2,i%9+1,(i/9+2)*(i%9+1));
i++;
}
return 0;
}

AND

06/06/30 추가숙제

DEVELOP/C 2006. 7. 1. 17:47

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

#define ENTER 0x000d
#define SPACE 0x0020

void main()
{
unsigned int temp;
char temp2[10];

while(temp2[0] != ENTER)
{
printf("정수를 입력하세요 : ");
scanf("%s",&temp2);
temp=atoi(temp2);
printf("입력한 정수는 %d입니다.\n",temp);
fflush(stdin);
}

}

/*
키보드로부터 정수값을 반복적으로 입력 받아
입력 한 값을 출력합니다.
계속 반복하다가 숫자를 입력하지 않고
엔터만 치면 프로그램이 종료되도록 합니다.

실행결과는 다음과 같습니다.

------------------------------------------
정수를 입력하세요 : 10(엔터)
입력한 정수는 10입니다.

정수를 입력하세요 : 20(엔터)
입력한 정수는 20입니다.

정수를 입력하세요 : 30(엔터)
입력한 정수는 30입니다.

....(계속 반복함)

정수를 입력하세요 : (엔터)
*/

AND

06/07/03 숙제

DEVELOP/C 2006. 7. 1. 01:43

#include <stdio.h>

int main()
{
/* double baseFee=660, extraFee=88.5, taX=0.09, usAge=0, sumFee=0, totalFee=0;
printf("전기 사용량을 입력하세요(kw) :");
scanf("%lf",&usAge);
sumFee=baseFee+(usAge*extraFee);
totalFee=sumFee*(1+taX);
printf("전기 사용요금은 %f원 입니다.",totalFee);

char backNum;
double hitRate;
int aGe;

printf("등번호를 입력하세요:");
scanf("%c",&backNum);

printf("타율을 입력하세요:");
scanf("%lf",&hitRate);

printf("나이를 입력하세요:");
scanf("%d",&aGe);

printf("%c번 선수의 타율은 %lf이고 나이는 %d살입니다.",backNum,hitRate,aGe);



char backNum, playerName[6], playerPostion[6];
double hitRate;
int aGe;

printf("등번호를 입력하세요:");
scanf("%c",&backNum);

printf("이름을 입력하세요:");
scanf(" %s",playerName); //배열에는 &를 사용치 않음,배열이므로 %s

printf("포지션을 입력하세요:");
scanf(" %s",playerPostion); //배열

printf("타율을 입력하세요:");
scanf("%lf",&hitRate);

printf("나이를 입력하세요:");
scanf("%d",&aGe);

printf("%c번-%s-%s, 타율은 %lf이고 나이는 %d살입니다.",backNum,playerName,playerPostion,hitRate,aGe);

*/

int hisTory,liteRate,aRt,sUm;
double aVg;
printf("역사, 문학, 예능 점수를 입력하세요 :");
scanf("%d%d%d",&hisTory,&liteRate,&aRt);
sUm=hisTory+liteRate+aRt;
aVg=sUm/3;

printf("총점은 %d이고 평균은 %lf입니다",sUm,aVg);
/*

int timeConstant, timeHour,timeMin,timeSec, temp;
timeConstant=32767;
timeHour=timeConstant/60/60;
timeMin=(timeConstant-timeHour*60*60)/60;
// timeSec=(timeConstant-timeHour*60*60-timeMin*60);
timeSec=timeConstant%60;
printf("%d초는 %d시간, %d분, %d초입니다.",timeConstant, timeHour,timeMin,timeSec);


double preciseDay=365.2422, temp;
long calDay,calHour,calMin,calSec;

//calDay=preciseDay;
//calHour=(preciseDay-calDay)*24;
//calMin=(preciseDay*24-calDay*24-calHour)*60;
//calSec=(preciseDay*24*60-calDay*24*60-calHour*60-calMin)*60;
//위에처럼 풀면 소수점 아래 7번째에서 반올림되는 부분때문에 오류가 남

calDay=preciseDay;
temp=preciseDay*24-calDay*24;

//printf("%f",temp);
calHour=temp;
temp=temp*60-calHour*60;

//printf("%f",temp);
calMin=temp;
temp=temp*60-calMin*60;

//printf("%f",temp);
calSec=temp;


printf("1년은 %d일, %d시간, %d분, %d초입니다.",calDay,calHour,calMin,calSec);
*/
return 0;
}

AND

06/06/30 숙제

DEVELOP/C 2006. 6. 30. 19:54

int a=9;
printf("내가 가장 좋아하는 숫자는 : %d",a);


printf("월드컵은\n2002년에\n개최되었습니다.");

int height, weight, cha;
printf("키:");
scanf("%d",&height);
printf("몸무게:");
scanf("%d",&weight);
cha=height-weight;
printf("키에서 몸무게를 뺀 값은 %d입니다.",cha);

printf("두 정수값을 입력하세요 :");
scanf("%d%d",&a, &b);
hap=a+b;
printf("두 정수의 합은 %d입니다.",hap);



AND

06/06/30 수업내용

DEVELOP/C 2006. 6. 30. 15:15

함수:특별한 기능을 수행하는 단위코드

printf("은하철도 999");
printf("은하철도%d", 999);

이름\t나이
===========
성춘향\t16

printf("A");
printf("\101"); //8진수
printf("\x41"); //16진수

AAA

\n new line
\r carriage return
\b back space
\t tab //8칸 간격


변수선언 -> 예약어 + 변수명

scanf("%d",&a);

#include <stdio.h>
//신상명세

void main()
{
int mAge;
float mHeight,mWeight;
char mName[6],mGender[5],mBlood[2];

printf("이름:");
scanf("%s",&mName);

printf("나이:");
scanf("%d",&mAge);

printf("키:");
scanf("%f",&mHeight);

printf("몸무게:");
scanf("%f",&mWeight);

printf("성별:");
scanf("%s",&mGender);

printf("혈액형:");
scanf("%s",&mBlood);

printf("%s\t%d\t%f\t%f\t%s\t%s",mName,mAge,mHeight,mWeight,mGender,mBlood);
}


화이트 스페이스
{
엔터
스페이스

}
//입력을 구분해주는 3가지

scanf는
키보드에서 버퍼값을 저장해놓고
그값을 차례로 스캔해서 값을 가져간다.
자신이 원하는 형식의 값이 아닌경우 그 앞까지만 가져감

따라서 숫자와 문자를 차례로 입력받을때는 알아서 가져가지만
문자와 숫자를 받을때는
숫자를 문자처럼 인식해서 가져가므로 정상작동하지 않는다.

\n라인의경우도 문자처럼 인식
해결법은 " %c" or "\n%c" or "\t%c"
화이트 스페이스는 스킵해라라는 의미


변수명 규칙
A~Z,a~z,0~9
첫문자는 숫자x
예약어 금지

AND

06/06/29 수업내용

DEVELOP/C 2006. 6. 29. 14:15

준비

입력

처리

출력

%d 숫자
%2d 2칸이상의 숫자


include

void main()
{
int movedDistance=300;
int slugDaySpeed=55;
int slugNightSpeed=13;
int passedDate=0;
int dayCount=0;

cout << movedDistance << "/" << dayCount;
cout << "\n";

while(movedDistance>=0)
{
dayCount=dayCount+1;
if (movedDistance>=0)
{
movedDistance=movedDistance-slugDaySpeed;
}
cout << movedDistance << "/" << dayCount;
cout << "\n";
if (movedDistance>=0)
{
movedDistance=movedDistance-slugNightSpeed;
}
cout << movedDistance << "/" << dayCount;
cout << "\n";
}
}

피보나치수열
#include <iostream.h>
int main()
{
int a=1,b=0,c=0;

while(a<=500)
{
cout << a <<endl;
c=a;
a=a+b;
b=c;
}
return 0;
}

AND

이름/나이/몸무게

DEVELOP/C 2006. 6. 29. 08:59

#include <iostream.h>
typedef unsigned short int USHORT;

class wish
{
public:
char myname[30];
int myage;
int myweight;
};

void checkweight(int weight);

void main()
{
// USHORT width=5;
// USHORT length=6;
// USHORT area;
// area=width*length;
// cout << area;

wish sch;
cout << "이름?";
cin >> sch.myname;
cout << "나이?";
cin >> sch.myage;
cout << "몸무게?";
cin >> sch.myweight;
cout << sch.myname << sch.myage << sch.myweight;
checkweight(sch.myweight);
}

void checkweight(int weight)
{
if (weight>=70)
cout << "살좀빼라";
else
cout << "밥좀먹어라";
}

AND

//2진수형식표현
#include

void main()
{
long a=0, b=10, temp=0, i=1;
cout << "Input A Plz";
cout << "\n";
cin >> a;
while (b!=0)
{
b=a/2;
temp=temp+(a%2)*i;
a=b;
i=i*10;
cout << "\n";
}
cout << temp;
}

//구구단
#include <iostream.h>

void main()
{
int i, j;
for(i=2;i<10;i++)
{
 for(j=2;j<10;j++)
 {
  cout << i << "x" << j << "=" << i*j;
  cout << "\t";
 }
  cout << "\n";
 
}
}

AND