# 추억의 C언어 입문(마름모 출력) ----- PC에 보관 된 자료를 찾다 보니 처음 C언어를 배울 때 학원에 가서 첫주에 배웠던 코딩이 아직까지 가지고 있어서 추억을 떠올리며 post를 작성을 해봅니다. 처음 C언어를 배우면 이 문장에서 시작합니다. <center>![](https://i.imgur.com/7B1jpGE.jpg)</center> <center>![](https://i.imgur.com/vEgZFTD.jpg)</center> 첫날 "Hellow World!" 문장은 국민 입문 코딩이지요. 이걸 배우고 나면 두번째 시간에는 더하기, 빼기, 곱, 나누기 등 사칙 연산을 코딩을 배웠었죠. 그리고 합 등을 배우면서 이틀날이 지나가게 됩니다. 그 다음 조건문 if, for, while, switch 문 등을 배우게 되는데 이때 for문에 국민 과제로 내주는 구구단과 마름모 출력이 떠오르네요. ## 마름모 출력 ----- ``` #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i,j; int a; printf("마름모 *의 수를 입력하시오:"); scanf("%d",&a); printf("\n"); a = a / 2+1; for(i = 0; i < a; i++) { for(j = i+1; j < a; j++) printf(" "); for(j = 0; j <= i*2; j++) printf("*"); printf("\n"); } for(i =a-2; i >= 0; i--) { for(j = i+1; j < a; j++) printf(" "); for(j = 0; j <= i*2; j++) printf( "*" ); printf( "\n" ); } system("PAUSE"); return 0; } ``` 예전에 코딩했던 마름모 출력 코딩이네요. 구구단과 마름모는 for문 입문 과제의 양대산맥이라 할 수 있는 주제이지요. 그 결과는 다음과 같습니다. <center>![](https://i.imgur.com/d3adMrV.jpg)</center> input 창에 5라는 숫자를 세팅해 놓고 온라인 C 컴파일로 돌렸을 때 보시는 것 처럼 5개짜리 마름모가 생성이 됩니다. 핵심은 ``` a = a / 2+1; ``` 위 코딩입니다. a라는 값은 초기 이벽 값은에서 중간 라인을 잡고 위쪽 삼각모양과 아래쪽 삼각모양을 for문을 사용하여 출력하는 예제입니다. 3차 for문을 이용했는데 for문에 있는 printf()문이 공백과 별표를 가 어떻게 출력 되는지 원리를 이해하시면 쉽게 코딩할 수 있는 예제입니다. ## 마무리 ----- 추억의 코딩이라서 간단히 올려 봤네요. 이 마름로를 이해하시면 for문을 제대로 사용할 수 있는 능력을 갖추게 됩니다. 그래서 국민 예제로 C언어 입문자들이 꼭 한번쯤은 코딩하고 넘어가는 예제이지요. 이 예제를 기반으로 다양한 별표 모양을 만들 수 있게 되는데 그 부분은 여러분들이 한번 소스를 분석하시고 개조해 보세요. --- ##### <sub> **Sponsored ( Powered by [dclick](https://www.dclick.io) )** </sub> [![dclick-imagead](https://steemitimages.com/0x0/https://cdn.steemitimages.com/DQmSwkE4cySARFCKdemZWVwyk8dxh7HeDNiqwuVmWR3RBXE/Group%205.png)](https://api.dclick.io/v1/c?x=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjIjoiY29kaW5nbWFuIiwicyI6Ii1jLS0xNTUwMDE3NjY1NjYxIiwiYSI6WyJpLTIiXSwidXJsIjoiaHR0cHM6Ly93d3cuZGNsaWNrLmlvIiwiaWF0IjoxNTUwMDE3NjY1LCJleHAiOjE4NjUzNzc2NjV9.zCMA_1knOIZsSQBVC8c5D0zCQTNE43tmwKz1Kdsr-X0)
post_id | 70,086,791 | ||||||
---|---|---|---|---|---|---|---|
author | codingman | ||||||
permlink | -c--1550017665661 | ||||||
category | kr-dev | ||||||
json_metadata | {"tags":["kr-dev","jjangjjangman","busy","kr","dclick"],"app":"busy\/2.5.6","format":"markdown","community":"busy","users":[],"links":["https:\/\/www.dclick.io","https:\/\/api.dclick.io\/v1\/c?x=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjIjoiY29kaW5nbWFuIiwicyI6Ii1jLS0xNTUwMDE3NjY1NjYxIiwiYSI6WyJpLTIiXSwidXJsIjoiaHR0cHM6Ly93d3cuZGNsaWNrLmlvIiwiaWF0IjoxNTUwMDE3NjY1LCJleHAiOjE4NjUzNzc2NjV9.zCMA_1knOIZsSQBVC8c5D0zCQTNE43tmwKz1Kdsr-X0"],"image":["https:\/\/i.imgur.com\/7B1jpGE.jpg","https:\/\/i.imgur.com\/vEgZFTD.jpg","https:\/\/i.imgur.com\/d3adMrV.jpg","https:\/\/steemitimages.com\/0x0\/https:\/\/cdn.steemitimages.com\/DQmSwkE4cySARFCKdemZWVwyk8dxh7HeDNiqwuVmWR3RBXE\/Group%205.png"]} | ||||||
created | 2019-02-13 00:27:45 | ||||||
last_update | 2019-02-13 00:29:00 | ||||||
depth | 0 | ||||||
children | 4 | ||||||
net_rshares | 3,965,911,996,412 | ||||||
last_payout | 2019-02-20 00:27:45 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 1.358 SBD | ||||||
curator_payout_value | 0.445 SBD | ||||||
pending_payout_value | 0.000 SBD | ||||||
promoted | 0.000 SBD | ||||||
body_length | 2,113 | ||||||
author_reputation | 23,203,609,903,979 | ||||||
root_title | "추억의 C언어 입문(마름모 출력)" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 SBD | ||||||
percent_steem_dollars | 10,000 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
guest123 | 0 | 745,178,723 | 100% | ||
busy.pay | 0 | 263,639,083,437 | 1.28% | ||
skan | 0 | 858,070,461,007 | 16% | ||
sisilafamille | 0 | 541,396,826 | 100% | ||
stylegold | 0 | 5,199,600,647 | 100% | ||
bramd | 0 | 1,557,627,717,469 | 20% | ||
krfeed | 0 | 261,024,601 | 100% | ||
car-engineer | 0 | 10,130,281,950 | 100% | ||
dj-on-steem | 0 | 7,584,075,121 | 31% | ||
codingman | 0 | 48,073,643,917 | 100% | ||
pyth0n | 0 | 793,791,368 | 100% | ||
newage92 | 0 | 14,161,269,317 | 100% | ||
flightsimulator | 0 | 22,527,223,498 | 100% | ||
jungjunghoon | 0 | 113,372,070,519 | 25% | ||
dera123 | 0 | 14,358,653,794 | 5% | ||
dorian-lee | 0 | 10,683,467,291 | 100% | ||
sebasi-steem | 0 | 493,864,740 | 100% | ||
pill.atmos | 0 | 5,229,263,915 | 100% | ||
garrettwallace | 0 | 73,488,618 | 1% | ||
powerguy | 0 | 641,486,044,796 | 20% | ||
anpigon | 0 | 89,483,649,999 | 100% | ||
jini-zzang | 0 | 3,692,844,382 | 100% | ||
bukio | 0 | 256,854,805,547 | 2.09% | ||
rideg | 0 | 35,184,778,406 | 50% | ||
talken | 0 | 1,281,522,392 | 100% | ||
steemory | 0 | 4,362,794,132 | 100% |
짱짱맨 호출에 응답하였습니다.
post_id | 70,087,220 |
---|---|
author | bukio |
permlink | re-bukio-jjangjjangman-1550018598055 |
category | kr-dev |
json_metadata | {"tags":["bukio","jjangjjangman"],"app":"steemer\/1.0"} |
created | 2019-02-13 00:43:18 |
last_update | 2019-02-13 00:43:18 |
depth | 1 |
children | 1 |
net_rshares | 0 |
last_payout | 2019-02-20 00:43:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 16 |
author_reputation | 12,334,203,545,676 |
root_title | "추억의 C언어 입문(마름모 출력)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
짱짱맨 방문 감사해요
post_id | 70,092,922 |
---|---|
author | codingman |
permlink | re-bukio-re-bukio-jjangjjangman-1550018598055-20190213t042714554z |
category | kr-dev |
json_metadata | {"tags":["kr-dev"],"app":"steemit\/0.1"} |
created | 2019-02-13 04:27:18 |
last_update | 2019-02-13 04:27:18 |
depth | 2 |
children | 0 |
net_rshares | 0 |
last_payout | 2019-02-20 04:27:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 11 |
author_reputation | 23,203,609,903,979 |
root_title | "추억의 C언어 입문(마름모 출력)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
저는 애플소프트로 언어를 배웠지만 이맘때가 가장 재밌었던것 같습니다. Posted using [Partiko iOS](https://steemit.com/@partiko-ios)
post_id | 70,087,881 |
---|---|
author | jungjunghoon |
permlink | jungjunghoon-re-codingman--c--1550017665661-20190213t010809840z |
category | kr-dev |
json_metadata | {} |
created | 2019-02-13 01:08:15 |
last_update | 2019-02-13 01:08:15 |
depth | 1 |
children | 1 |
net_rshares | 0 |
last_payout | 2019-02-20 01:08:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 101 |
author_reputation | 831,763,771,102,670 |
root_title | "추억의 C언어 입문(마름모 출력)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
오래전이지만 그때 진짜 C언어 재밌게 배웠던 것 같아요.
post_id | 70,092,934 |
---|---|
author | codingman |
permlink | re-jungjunghoon-jungjunghoon-re-codingman--c--1550017665661-20190213t042743767z |
category | kr-dev |
json_metadata | {"tags":["kr-dev"],"app":"steemit\/0.1"} |
created | 2019-02-13 04:27:48 |
last_update | 2019-02-13 04:27:48 |
depth | 2 |
children | 0 |
net_rshares | 0 |
last_payout | 2019-02-20 04:27:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 31 |
author_reputation | 23,203,609,903,979 |
root_title | "추억의 C언어 입문(마름모 출력)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |