#include 의 프로필
회원번호 |
231310 |
닉네임 |
#include |
가입일 |
2010-08-10 16:18:28 |
로그인 |
4705 회 |
승자예상 |
-146,816 (91503 위) / 89승 107패
|
오목전적 | 없음 | 장기전적 | 없음 |
#include <iostream>#include <cstdlib>#include <time.h>
using namespace std;
void body(int up[4][4],char down[4][4]);void pyo(char print[4][4]);void hwa(int a, int b,int up[4][4],char down[4][4]);
int main(){ int i,j; int Size=4; int nRand[4][4]; char down[4][4]; int a=1; srand(time(NULL));
for(i=0;i<2;i++){ for(j=0;j<4;j++){ nRand[i][j]=a; nRand[i+2][j]=a; a=a+1;;} } for(i=0;i<4;i++){ for(j=0;j<4;j++){ int b=rand() %3; int c=rand() %3; int k=nRand[i][j]; nRand[i][j]=nRand[i][c]; nRand[i][c]=k; k=nRand[b][j]; nRand[b][j]=nRand[b][c]; nRand[b][c]=k;} }
//윗 부분이 랜덤 숫자 배열 부분. for(i=0;i<4;i++) for(j=0;j<4;j++){ down[i][j]='*';}
body(nRand,down);
}
void body(int up[4][4],char down[4][4]){
int a,b,c,d;
system("cls");
pyo(down);
cout<<endl<<"첫 좌표는?"<<endl; cin>>a>>b; down[a-1][b-1]=up[a-1][b-1];
pyo(down);
cout<<endl<<"다음 좌표는?"<<endl; cin>>c>>d;
//좌표값을 입력 받는 부분
down[c-1][d-1]=up[c-1][d-1];
if(down[a-1][b-1]!=down[c-1][d-1]){ cout<<endl<<"서로 다름"<<endl<<endl; pyo(down); system("pause");
down[a-1][b-1]='*'; down[c-1][d-1]='*';
body(up,down);}
else if(down[a-1][b-1]==down[c-1][d-1]){ pyo(down);
cout<<endl<<"같음"<<endl<<endl;
system("pause");
body(up,down);}}
// 위의 부분이 게임의 본체 부분, 위의 과정을 통해 두 수가 같음과 다름을 보고 "서로 다름", "같음"을 출력해줌
void pyo(char print[4][4]){ int i,j; cout<<" | 1 2 3 4 "<<endl <<"-----------------"<<endl; for(i=0;i<4;i++) for(j=0;j<4;j++){ if(j==0){ if(i==0){cout<<" 1 | ";} if(i==1){cout<<" 2 | ";} if(i==2){cout<<" 3 | ";} if(i==3){cout<<" 4 | ";}
} if(print[i][j]!='*'){printf("%d ",print[i][j]);} else printf("%c ",print[i][j]); if(j!=3) continue; {cout<<endl;} } }#include <stdio.h>#include <stdlib.h>#include <string.h>
typedef struct ListNode{ char data[10]; struct ListNode* link;}listNode;
typedef struct{ listNode* head;}linkedList_h;
linkedList_h* createLinkedList_h(void);void addFirstNode(linkedList_h*, char*);void deleteFirstNode(linkedList_h*);void printList(linkedList_h*);
linkedList_h* creatLinkedList_h(void){ linkedList_h* L; L=(linkedList_h*)malloc(sizeof(linkedList_h)); L->head = NULL; return L;}
void addFirstNode(linkedList_h* L, char* x){ listNode* newNode; listNode* p; newNode = (listNode*)malloc(sizeof(listNode)); strcpy(newNode->data, x); newNode->link= NULL; if(L->head==NULL) { L->head=newNode; return; } else{ p=L->head; L->head=newNode; newNode->link=p; }}
void deleteFirstNode(linkedList_h* L){
listNode* temp; if(L->head==NULL) return; if(L->head->link==NULL) { free(L->head); L->head = NULL; return; } else { temp=L->head; L->head=L->head->link; free(temp); }}
void printList(linkedList_h* L){ listNode* p; printf("L=("); p=L->head; while(p!=NULL) { printf("%s", p->data); p=p->link; if(p!=NULL) printf(", "); }
printf(") \n");}
int main(){ linkedList_h* L; L=creatLinkedList_h(); printf("(1) 공백 리스트 생성하기! \n"); printList(L); getchar();
printf("(2) 리스트에 3개의 노드 추가하기! \n"); addFirstNode(L, "금"); addFirstNode(L, "수"); addFirstNode(L, "월"); printList(L); getchar();
printf("(3) 처음 리스트를 삭제하기! \n"); deleteFirstNode(L); printList(L); getchar();
printf("(4) 리스트 처음에 노드 한개 추가하기! \n"); addFirstNode(L, "화"); printList(L); getchar();
getchar(); return 0;}
님 게시글에 음악까는거 어떻게하죠 ? 알고싶어요
미국학교에서 지금 이런거 비슷한거 하고있는데 너무어려워서 ㅋㅋ
헐ㅋㅋ 미안하실 필요까지는 ㅠㅠ 그냥 불러워서 싸질른건데;;
나랑 친구하자 나도 c언어좀 한다 ㅋㅋㅋㅋㅋ
참고로 난 avr_studio 씀 ㅋㅋㅋㅋㅋ