Please enable JavaScript in your browser to load website properly.

Click here if you'd like to learn how. 와이고수
채팅 0
게임 0
유물

#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;}
감사합니다~
좋은하루되세요 ^^

2013-02-02 04:27:43

답글달기

글 잘 보고 있습니다 -와고10년차

2013-01-28 13:16:40

답글달기

요즘 부쩍 훈훈한글을 많이싸지르는구나 

2010-12-13 12:36:59

답글달기

오감사 미네랄드림 

2010-12-09 09:49:32

답글달기

님 게시글에 음악까는거 어떻게하죠 ? 알고싶어요

2010-12-08 17:31:19

답글달기

미국학교에서 지금 이런거 비슷한거 하고있는데 너무어려워서 ㅋㅋ

2010-12-05 09:26:51

답글달기

헐ㅋㅋ 미안하실 필요까지는 ㅠㅠ 그냥 불러워서 싸질른건데;;

2010-12-05 09:26:11

답글달기

프로필 씹 허세난뭌ㅋㅋㅋ

2010-12-04 10:53:31

답글달기

나랑 친구하자 나도 c언어좀 한다 ㅋㅋㅋㅋㅋ

참고로 난 avr_studio 씀 ㅋㅋㅋㅋㅋ

2010-11-24 09:29:57

답글달기

컴공인데 c언어 넘어려 ㅠ

2010-11-23 00:36:51

답글달기

최신 이전 1 2 다음 끝

#include의 친구 (10)

  • 와고클릭반
  • 전국1등
  • 토성
  • 명왕
  • 션자이
  • 몽치
  • 와고클릭친추
  • 과거
  • 와고잉어반
  • 쩌리!
  • TODAY : 1
  • YESTERDAY : 0
  • TOTAL : 873
RSS FEED