#include <stdio.h> #include <conio.h> void main() { //변수선언 int num[6]; int *add=num; int r,i,l; //5개의 숫자 입력 for(r=0;r<=4;r++) { printf("\n5개의 숫자를 입력하세요="); scanf("%d",&num[r]); } //배열의 주소값과 갑들출력 for(i=0;i<=4;i++) printf("address=%u,num[%d]=%d\n",&num[i],i,num[i]); //가장높은수를 알아내기위한 비교 int temp=*add; for(l=0;l<5;l++) { add++; for(int a=0;a<5;a++) { if(temp<=*add) { temp=*add; } } } //높은수 출력 printf("max=%d\n",temp); }
#include <iostream.h> // 구버전의 C++일경우 iostream.h void PrintBit(int n) { for(int i=1<<16; i>0; i>>=1){ // 최상위비트부터 1비트씩 이동 if(n&i) cout << "1"; // 만일 비트가 1이면 1출력 else cout << "0"; // 만일 비트가 0이면 0출력 } cout << endl; } int main() { int n; cout << "숫자를 입력하세요: "; cin >> n; PrintBit(n); return 0; }
예전에 락현이형이 짰던거.....
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
#define ESC 27
int x,y;
// 콘솔화면화면(도스화면) 상의 x,y위치로 커서를 이동시킨다.(콘솔화면 가로 0-79, 세로 0-25)
void gotoxy(int x, int y)
{
COORD Cur;
Cur.X=x;
Cur.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Cur);
}
void prx()
{
gotoxy(x,y);
putchar('*');
}
void main()
{
char usrinput;
x = 30,y=10;
while( usrinput != ESC )
{
prx();
/////////////////////////////////// 키보드로 부터 입력된 값이 특수문자(방향키)임을 먼저 확인하고 만약 방향키라면 어떤 방향인지
usrinput = getch(); // 조사한다.
if( usrinput == 0xE0 ) //
usrinput = getch(); //
///////////////////////////////////
switch(usrinput) {
case UP :
y--;
break;
case DOWN:
y++;
break;
case RIGHT:
x++;
break;
case LEFT:
x--;
break;
default :
break;
}
}
system("cls");
gotoxy(30,10);
printf("프로그램을 종료합니다.");
}
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
#define ESC 27
int x,y;
// 콘솔화면화면(도스화면) 상의 x,y위치로 커서를 이동시킨다.(콘솔화면 가로 0-79, 세로 0-25)
void gotoxy(int x, int y)
{
COORD Cur;
Cur.X=x;
Cur.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Cur);
}
void prx()
{
gotoxy(x,y);
putchar('*');
}
void main()
{
char usrinput;
x = 30,y=10;
while( usrinput != ESC )
{
prx();
/////////////////////////////////// 키보드로 부터 입력된 값이 특수문자(방향키)임을 먼저 확인하고 만약 방향키라면 어떤 방향인지
usrinput = getch(); // 조사한다.
if( usrinput == 0xE0 ) //
usrinput = getch(); //
///////////////////////////////////
switch(usrinput) {
case UP :
y--;
break;
case DOWN:
y++;
break;
case RIGHT:
x++;
break;
case LEFT:
x--;
break;
default :
break;
}
}
system("cls");
gotoxy(30,10);
printf("프로그램을 종료합니다.");
}