C언어소스

Category
아이템: 
포스트 갯수10

행렬의 덧셈

By Regular Admission Empire | 2018년 6월 12일 | 
#include <stdio.h>#define ROWS 3#define COLS 3 int main(void) { int r,c; int A[ROWS][COLS] = {{1,0,0},{0,1,0},{0,0,1}}; int B[ROWS][COLS] = {{1,0,0},{0,1,0},{0,0,1}}; int C[ROWS][COLS]; for(r=0;r<ROWS;r++){ for(c=0;c<COLS;c++){ C[r][c] =A[r][c]+B[r][c]; printf("%d",C[r][c]); } printf("\n"); } return 0;}

앵그리 공

By Regular Admission Empire | 2018년 5월 29일 | 
#include<windows.h> #include<stdio.h>int main() { HDC hdc = GetWindowDC(GetForegroundWindow()); int x=30, y=200; int vx=50, vy=-50; int i; MoveToEx(hdc,30,200,NULL); LineTo(hdc,800,200); for (i=0;i<20;i++){ vy=vy+10; x=x+vx; y=y+vy; Ellipse(hdc, x, y, x+10,y+10); Sleep(100); } }

숫자 추측 게임

By Regular Admission Empire | 2018년 5월 29일 | 
#include<stdio.h> int main() { int a = rand()%100; int b; int c = 0; do{ printf("정답을 추측하여 보시오: "); scanf("%d", &b); c++; if (b >a ) printf("제시한 정수가 높습니다.\n"); if (b < a) printf("제시한 정수가 낮습니다.\n"); } while (b != a); printf("축하합니다. 시도횟수=%d\n", c); return 0; }

while 문을 이용한 제곱값 출력 프로그램

By Regular Admission Empire | 2018년 5월 29일 | 
#include<stdio.h>int main() { int a; printf("====================\n"); printf(" n n의 제곱\n"); printf("====================\n"); a = 1; while (a <= 10) { printf("%5d %5d\n", a, a*a); a++; } return 0; }