게시판 게시물

YANNDCH
2019년 11월 16일
In 소스 코드 제출
#include <stdio.h> #include <math.h> #include <string.h> #include <conio.h> #include <stdlib.h> #include <Windows.h> #define SIZE 10 #define LEFT 75 #define RIGHT 77 #define UP 72 #define DOWN 80 int map[SIZE][SIZE]; void generateMap(int k); void gotoxy(int x,int y); int main() { char key; int k=0; int i, j; int playerX, playerY; scanf("%d", &k); system("cls"); generateMap(k); for(i=0; i<SIZE; i++) { for(j=0; j<SIZE; j++) { switch(map[i][j]) { case 1: //wall printf("#"); break; case 9: //player printf("+"); playerX = i; playerY = j; break; case 2: //star printf("*"); break; case 3: //ball printf("O"); break; default: printf(" "); } } printf("\n"); } for(;;) { gotoxy(15, 2); printf("%d %d", playerX, playerY); for(i=0; i<10; i++) { for(j=0; j<10; j++) { gotoxy(23+j, 2+i); printf("%d", map[i][j]); } } //system("cls"); key = getch(); gotoxy(playerX, playerY); switch(key) { case UP: if( map[playerX-1][playerY] != 1 ) { if ( map[playerX-1][playerY] == 3 && map[playerX-2][playerY] == 0 ) { printf(" "); //playerY--; map[playerX][playerY] = 0; playerY--; map[playerX][playerY] = 9; printf("+"); map[playerX-1][playerY] = 3; gotoxy(playerX-1, playerY); printf("O"); } else { } printf(" "); map[playerX][playerY] = 0; playerY--; map[playerX][playerY] = 9; gotoxy(playerX, playerY); } break; case DOWN: if( map[playerX+1][playerY] != 1 ) { if ( map[playerX+1][playerY] == 3 && map[playerX+1][playerY] != 1 ) { printf(" "); playerY++; gotoxy(playerX+2, playerY); printf("O"); } printf(" "); map[playerX][playerY] = 0; playerY++; map[playerX][playerY] = 9; gotoxy(playerX, playerY); printf("+"); } break; case RIGHT: if( map[playerX][playerY+1] != 1 ) { if ( map[playerX][playerY+1] == 3 && map[playerX][playerY+2] != 1 ) { printf(" "); playerX++; gotoxy(playerX, playerY+2); printf("O"); } printf(" "); map[playerX][playerY] = 0; playerX++; map[playerX][playerY] = 9; gotoxy(playerX, playerY); printf("+"); } break; case LEFT: if( map[playerX][playerY-1] != 1 ) { if ( map[playerX][playerY-1] == 3 && map[playerX][playerY-2] != 1 ) { printf(" "); playerX--; gotoxy(playerX, playerY-2); printf("O"); } printf(" "); map[playerX][playerY] = 0; playerX--; map[playerX][playerY] = 9; gotoxy(playerX, playerY); printf("+"); } break; } } } void gotoxy(int x,int y) { COORD pos= {x,y}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } void generateMap(int k) { int i, j; // 1 = wall // 2 = star // 3 = ball // 9 = player if(k==1) // map step { int m[SIZE][SIZE] = { {1,1,1,1,1,1,1,1,1,1}, {1,9,0,0,0,3,0,0,2,1}, {1,0,0,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,0,0,1}, {1,0,0,0,0,0,0,0,0,1}, {1,1,1,1,1,1,1,1,1,1} }; for(i=0; i<SIZE; i++) { for(j=0; j<SIZE; j++) { map[i][j] = m[i][j]; } } } else if(k==2) { } } // 특수문자 작업중 \\ /** #include <stdio.h> #include <math.h> #include <string.h> #include <conio.h> #include <stdlib.h> #include <Windows.h> #define SIZE 20 #define LEFT 75 #define RIGHT 77 #define UP 72 #define DOWN 80 int map[SIZE/2][SIZE]; void generateMap(int k); void gotoxy(int x,int y); int main() { char key; int k=0; int i, j; int playerX, playerY; scanf("%d", &k); system("cls"); generateMap(k); for(i=0; i<SIZE; i++) { for(j=0; j<SIZE; j++) { switch(map[i][j]) { case 1: printf("▩"); break; case 9: printf("●"); playerX = i; playerY = j; break; default: printf("□"); } } printf("\n"); } for(;;) { //system("cls"); key = getch(); gotoxy(40, 4); printf("%d %d\n", playerX, playerY); gotoxy(playerX, playerY); switch(key) { case LEFT: if( map[playerX-2][playerY] != 1 ) { printf("□"); playerX-2; gotoxy(playerX, playerY); printf("●"); gotoxy(playerX, playerY); } break; case RIGHT: if( map[playerX+2][playerY] != 1 ) { printf("□"); playerX+2; gotoxy(playerX, playerY); printf("●"); gotoxy(playerX, playerY); } break; case DOWN: if( map[playerX][playerY+2] != 1 ) { printf("□"); playerY+=2; gotoxy(playerX, playerY); printf("●"); gotoxy(playerX, playerY); } break; case UP: if( map[playerX][playerY-2] != 1 ) { printf("□"); playerY-2; gotoxy(playerX, playerY); printf("●"); gotoxy(playerX, playerY); } break; } } } void gotoxy(int x,int y) { COORD pos= {x,y}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } void generateMap(int k) { int i, j; // 1 = wall // 2 = star // 3 = ball // 9 = player if(k==1) // map step { int m[SIZE/2][SIZE] = { {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,0,9,0,0,0,0,0,0,0,0,0,0,0,2,0,3,0,1,0}, {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} }; for(i=0; i<SIZE/2; i++) { for(j=0; j<SIZE; j++) { map[i][j] = m[i][j]; } } } **/
0
0
2
YANNDCH
2019년 11월 02일
In 소스 코드 제출
#include <stdio.h> #include <stdlib.h> /* int d(int n); int main() { int n; scanf("%d", &n); printf("%d", d(n)); } int d(int n) { if(n<=2) return 1; return d(n-2) + d(n-1); } */ /* int main(){ int n; scanf("%d", &n); printf("%d", n); printf("\n"); d(n); } int d(int n){ if(n==1){ exit(1); } if(n%2==1){ n=3*n+1; printf("%d", n); printf("\n"); d(n); }else{ n=n/2; printf("%d", n); printf("\n"); d(n); } } */ /* #include<stdio.h> void rain(int n) { if(n==1) { printf("1\n"); return ; } if(n%2==0) { rain(n/2); printf("%d\n", n); } else { rain(n*3+1); printf("%d\n", n); } } int main() { int n; scanf("%d", &n); rain(n); } */ /* int main() { int n; scanf("%d", &n); if(n==0){ printf("0"); }else{ d(n); } } void d(int n) { if(n==0) return ; d(n/2); printf("%d", n%2); } */ /* int main(){ int s,m,e; scanf("%d", &e); d(s,m,e); } void d(int s, int m, int e){ if(s==e){ exit(1); } if(s==m){ printf("*\n"); d(1,m+1,e); }else{ printf("*"); d(s+1,m,e); } } */ 191102
0
0
1
YANNDCH
2019년 10월 26일
In 소스 코드 제출
#include <stdio.h> #include<stdlib.h> /* void d(int a, int b) { if(a!=b) { if(a<=0) { return ; } printf("%d ", a); d(a+2,b); } else{ exit(1); } } int main() { int a,b,a2,b2; scanf("%d %d", &a, &b); if(a%2==0) { a2=a+1; } else { a2=a; } if(b%2==0) { b2=b+1; } else { b2=b+2; } d(a2,b2); } */ /* #include<stdio.h> void f(int a, int b) { if(a>b) return; if(a%2==1) { printf("%d ", a); } f(a+1, b); } int main() { int a, b; scanf("%d %d", &a, &b); f(a, b); } */ /** int main() { int n; scanf("%d", &n); printf("%d", d(n) ); } int d(int n) { if(n==0) return 0; return n + d(n-1); } **/ /* int main() { int n; scanf("%d", &n); printf("%d", d(n) ); } int d(int n) { if (n==1) { return 1; } return n * d(n-1); } */ /** int main() { int n; scanf("%d", &n); printf("%d", d(n)); } int d(int n) { if(n<=2) return 1; return d(n-2) + d(n-1); } **/
0
0
1
YANNDCH
2019년 10월 19일
In 소스 코드 제출
#include <stdio.h> #include <stdlib.h> /**/ /* long long int n; // 이 부분에 들어가야 될 코드를 작성하여 제출 int sqrt(long long int n) { long long int i; for(i=0; i<n; i++) { if(i*i>n) { break; } } if(i==n){ return (int)n; }else{ return (int)i-1; } } int main() { scanf("%lld", &n); printf("%d\n", sqrt(n)); return 0; } */ /**/ /* #include <stdio.h> int n, d[100010], k; // 이 부분에 들어가야 될 코드를 작성하여 제출 int f(int k) { int i, err0r; err0r =0; for(i=0; i<=n; i++) { if(d[i]==k){ break; }else{ err0r=err0r+1; } } if(err0r==n+1){ return -1; }else{ return i; } } */ /**/ /* int main() { scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%d", &d[i]); scanf("%d", &k); printf("%d\n", f(k)); } */ /* #include <stdio.h> double x; // 이 부분에 들어가야 될 코드를 작성하여 제출. double f(double x2) { return x-(long long int)x2; } int main() { scanf("%lf", &x); printf("%.14lf\n", f(x)); } */ /**/ /* #include<stdio.h> void rec(int n) { if(n<0) return ; rec(n-1); printf("%d ", n); } int main() { int n; scanf("%d", &n); rec(n); } */ /* printf(n); rec(n-1); rec(n-1); { rec(n-2); { rec(n-3); { } printf(n-2); } printf(n-1); } printf(n); */ /* void d(int n){ if(n<=0){ return ; } d(n-1); printf("%d\n", n); } int main(){ int n; scanf("%d", &n); d(n); } */ void d(int n2) { } int main(){ int n; scanf ("%d", &n); d(n); }
0
0
2
YANNDCH
2019년 9월 28일
In 소스 코드 제출
#include <stdio.h> #include <stdlib.h> /* int main() { int i, j, n, k=1; int ans = 0; int arr[101][101]={}; scanf("%d", &n); for(i=0; i<n; i++) { for(j=0; j<n; j++) { arr[i][j] = k++; } } for(i=0; i<n; i++){ for(j=0; j<n; j++){ if(i==0||j==0||i==(n-1)||j==(n-1)) { ans=ans+arr[i][j]; } } } printf("%d", ans); } */ /* int main() { int i, j, n = 0; int arr[20][20]; for(i=0; i<11; i++) { for(j=0; j<10; j++) { scanf("%d", &arr[i][j]); } for(j=0; j<=10; j++) { if(arr[10][j]==1) { for(n=9; n>=0; n--) { if(arr[n][j]<0) { printf("%d fall\n", j+1); break; } if(arr[n][j]>0) { printf("%d crash\n", j+1); break; } } if(n==-1) { printf("%d safe\n", j+1); } } } } } */
0
0
3
YANNDCH
2019년 8월 03일
In 소스 코드 제출
/* #include <stdio.h> int main() { int a; scanf("%d", &a); if (a==0){ printf("1"); }else if (a==1){ printf("0"); } return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); if (a==1&&b==1){ printf("1"); }else{ printf("0"); } return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); if (a==1||b==1){ printf("1"); }else{ printf("0"); } return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); if (!a==b){ printf("1"); }else{ printf("0"); } return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); if (a==b){ printf("1"); }else{ printf("0"); } return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); printf("%d", a&&b); return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d", &a); printf("%d", !a); return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); printf("%d", a||b); return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); printf("%d", !a&&b); return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); printf("%d", !(a||b)); return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d", &a); printf("%x", a); return 0; } */ /* #include <stdio.h> int main() { int a, b; scanf("%d", &a); printf("%o", a); return 0; } */ /* #include <stdio.h> int main(){ int a, b; scanf("%d", &a); printf("%x", a); return 0; } */ /* #include <stdio.h> int main(){ int a, b; scanf("%d", &a); printf("%X", a); return 0; } */ /* #include <stdio.h> int main(){ int a, b; scanf("%o", &a); printf("%d", a); return 0; } */ /* #include <stdio.h> int main(){ int a, b; scanf("%x", &a); printf("%o", a); return 0; } */ /* #include <stdio.h> int main(){ char c; scanf("%c", &c); printf("%d", c); return 0; } */ /* #include <stdio.h> int main() { int a,b,c; scanf("%d %d %d", &a, &b, &c); if (c>=(a+b)){ printf("삼각형아님"); }else if (a==b&&b==c) { printf("정삼각형"); }else if (a==b||a==c||b==c) { printf("이등변삼각형"); }else if ((a*a+b*b)==c*c){ printf("직각삼각형"); }else{ printf("삼각형"); } return 0; } */ /* #include <stdio.h> int main (){ int a, b, c; scanf("%d", &a); b=a%10; a=a/10; c=(b*10+a)*2; if (c>=100){ c=c-100; } printf("%d", c); printf("\n"); if (c<=50){ printf("GOOD"); }else{ printf("OH MY GOD"); } return 0; } */
0
0
1
YANNDCH
2019년 7월 27일
In 소스 코드 제출
/* #include <stdio.h> int main() { printf("Hello"); return 0; } */ /* #include <stdio.h> int main() { printf("Hello World"); return 0; } */ /* #include <stdio.h> int main() { printf("Hello\nWorld"); return 0; } */ /* #include <stdio.h> int main() { printf("\'Hello\'"); return 0; } */ /* #include <stdio.h> int main() { printf("\"Hello World\""); return 0; } */ /* #include <stdio.h> int main() { printf("\"!@#$%%^&*()\""); return 0; } */ /* #include <stdio.h> int main() { printf("\"C:\\Download\\hello.cpp\""); return 0; } */ // int %d // long long %lld // float %f // double %lf // char %c /* #include <stdio.h> int main(){ int a; scanf("%d", &a); printf("%d", a); return 0; } */ /* #include <stdio.h> int main(){ float f; scanf("%f", &f); printf("%f", f); return 0; } */ /* #include <stdio.h> int main(){ char a; char b; scanf("%c %c", &a,&b); printf("%c %c", b, a); return 0; } */ /* #include <stdio.h> int main(){ int a; scanf("%d", &a); printf("%d %d %d", a, a, a); return 0; } */ /* #include <stdio.h> int main(){ int a; int b; int c; scanf("%04d.%02d.%02d", &a,&b,&c); printf("%04d.%02d.%02d", a,b,c); return 0; } */ /* #include <stdio.h> int main(){ char a[51]; scanf("%s", a); printf("%s", a); return 0; } */ /* #include <stdio.h> int main(){ int a; int b; scanf("%d.%d", &a, &b); printf("%d\n%d", a,b); return 0; } */ /* #include <stdio.h> int main(){ int a, b, c, d, e; scanf("%1d%1d%1d%1d%1d", &a, &b, &c, &d, &e); printf("[%d]\n", a*10000); printf("[%d]\n", b*1000); printf("[%d]\n", c*100); printf("[%d]\n", d*10); printf("[%d]\n", e*1); return 0; } */ /* #include <stdio.h> int main(){ int a,b,c; scanf("%d.%d.%d", &a,&b,&c); printf("%02d-%02d-%04d", c,b,a); return 0; } */ /* #include <stdio.h> int main() { long long int a,b,c; scanf("%lld %lld %lld", &a, &b, &c); printf("%lld\n", a+b+c); printf("%.1lf", (double)(a+b+c)/3); return 0; } */ #include<stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); printf("%d", a>b); }
0
0
1

YANNDCH

더보기