본문 바로가기

프로그램/C언어 1000제227

C언어 107제] C언어 콘서트 CHAPTER 11 Programming 7 열거형 사용하기 p456 출처 : 반크_세계유산 고인돌 참고풀이] //Dev-C++ 5.11로 작업함. #include #include //srand(), rand() #include //time() int main() { enum Game { kawee, bawee, bo}; int N; //player 변수 int C; //컴퓨터 변수 int chk; //결과승부 변수 //무작위 값을 산출하기 위한 초가값 설정 srand(time(NULL)); printf("가위(0), 바위(1), 보(2)를 입력하세요 : "); scanf("%d",&N); C=rand()%3; if(N==C) chk=0; else if(N==kawee) if(C==bo) chk=1; else if(C==bawee)chk=-1; else if(N==bawe.. 2022. 1. 19.
C언어 106제] C언어 콘서트 CHAPTER 11 Programming 6 재고를 검색하기 p456 출처 : 반크_세계유산 고인돌 참고풀이] //Dev-C++ 5.11로 작업함. #include #include //system() #include //strcmp() typedef struct PIMS { //Product Inventory Management System char product[20]; //상품명 변수 int price; //가격 변수 int count; //개수 변수 int total; //총재고액 변수 }pims; int main() { pims N[3];//상품재고 변수 char Search[20];//검색 변수 int i; int chk;//검색여부 파악 변수 //재고 자료를 입력합니다. for(i=0;i 2022. 1. 18.
C언어 105제] C언어 콘서트 CHAPTER 11 Programming 5 나이가 20이상 30 이하인 직원 출력하기 p456 출처 : 반크_세계유산 고인돌 참고풀이] //Dev-C++ 5.11로 작업함. #include typedef struct employee { int number; char name[20]; char phone[12]; int age; }em; int main() { em N[10]={ {220103001,"홍길동1","01012341234",20}, {220103002,"홍길동2","01012341235",22}, {220103003,"홍길동3","01012341236",33}, {220103004,"홍길동4","01012341237",32}, {220103005,"홍길동5","01012341238",34}, {220103006,"홍길동6","01012341239",31}, {220103007,"홍길동7.. 2022. 1. 18.
C언어 104제] C언어 콘서트 CHAPTER 11 Programming 4 두시간 사이의 차이를 계산하기 p455 출처 : 반크_세계유산 고인돌 참고풀이] //Dev-C++ 5.11로 작업함. #include typedef struct Time { int hour; int minute; int second; }uTime; uTime diff_time(uTime a, uTime b) { uTime result; result.second = b.second - a.second; result.minute = b.minute - a.minute; result.hour = b.hour - a.hour; if(result.second 2022. 1. 17.
C언어 103제] C언어 콘서트 CHAPTER 11 Programming 3 복소수 더하기 p455 출처 : 반크_가상독도전시관 참고풀이] //Dev-C++ 5.11로 작업함. #include typedef struct Complex { double x; double y; }Comp; Comp add_complex(Comp a, Comp b) { Comp result; result.x=a.x+b.x; result.y=a.y+b.y; return result; } int main() { Comp N1,N2;//복소수값을 입력할 변수 Comp R;//결과값을 넣을 변수 //자료를 입력합니다. printf("첫번째 복소수를 입력하시오 : "); scanf("%lf%lf",&N1.x,&N1.y); printf("두번째 복소수를 입력하시오 : "); scanf("%lf%lf",&N2.x,&N2.y); //처리부.. 2022. 1. 17.
C언어 102제] C언어 콘서트 CHAPTER 11 Programming 2 구조체 활용하여 이메일 표현하기 p455 출처 : 반크_가상독도전시관 참고풀이] //Dev-C++ 5.11로 작업함. #include #include //strlen() struct Email { char title[50]; //제목 char receiver[50];//수신자 char sender[50];//발신자 char contents[2000];//내용 char date[9];//날짜 int rank;//우선순위 }; void Line() { int i; for(i=1;i 2022. 1. 14.
C언어 101제] C언어 콘서트 CHAPTER 11 Programming 1 구조체 안에 공용체 사용한 구조체 선언하기 p455 출처 : 반크_가상독도전시관 참고풀이] //Dev-C++ 5.11로 작업함. #include #include //strlen(), strcpy() union Number{ char rrn[14];//주민등록번호 char colleague[9];//학번(년도+학년+반+번호) }; struct Student { union Number no; char name[20];//이름 char telephone[12];//전화번호 }; int main() { struct Student ban; char strno[14]={'\0'};//주민번호 또는 학번 입력변수 int i;//반복변수 //자료를 입력합니다. while(1) { printf("주민등록번호 또는 학번을 입력하시오(예:22010101) : "); scan.. 2022. 1. 14.
C언어 100제] C언어 콘서트 CHAPTER 11 p434 도전문제 3 문제를 랜덤하게 제시하고 출제된 문제는 다시 나오지 않도록 하기 p455 출처 : 반크_가상독도전시관 참고풀이] //Dev-C++ 5.11로 작업함. #include #include //srand(),rand() #include //strlen() #include //time() #include #define SIZE 100 void gotoxy(int x, int y) { COORD Pos={x,y}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Pos); } struct QUESTION { char question[SIZE]; char item1[SIZE]; char item2[SIZE]; char item3[SIZE]; char item4[SIZE]; int solution; }; struct QUESTION ba.. 2022. 1. 11.
C언어 99제] C언어 콘서트 CHAPTER 11 p434 도전문제 2 맞춘문제 카운트 하기 출처 : 반크_가상독도전시관 참고풀이] //Dev-C++ 5.11로 작업함. #include #include #include //strlen() #include #define SIZE 100 void gotoxy(int x, int y) { COORD Pos={x,y}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Pos); } struct QUESTION { char question[SIZE]; char item1[SIZE]; char item2[SIZE]; char item3[SIZE]; char item4[SIZE]; int solution; }; struct QUESTION bank[12] = { {"임베디드 장치에 가장 적합한 프로그래밍 .. 2022. 1. 11.
C언어 98제] C언어 콘서트 CHAPTER 11 p434 도전문제 1 10문제 더 추가하기 출처 : 반크_가상독도전시관 참고풀이] //Dev-C++ 5.11로 작업함. #include #include #include //strlen() #include #define SIZE 100 void gotoxy(int x, int y) { COORD Pos={x,y}; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Pos); } struct QUESTION { char question[SIZE]; char item1[SIZE]; char item2[SIZE]; char item3[SIZE]; char item4[SIZE]; int solution; }; struct QUESTION bank[12] = { {"임베디드 장치에 가장 적합한 프로그래밍 .. 2022. 1. 11.
C언어 97제] C언어 콘서트 CHAPTER 10 Programming 12 p416 출처 : 반크_가상독도전시관 참고풀이] //Dev-C++ 5.11로 작업함. #include #include //strcpy() char ELIZA[4][50]={ "Hi!", "My name is ELIZA. What's your name?", "Nice to meet you.", "Congratulate! CHAPTER 10을 끝마쳤습니다.", }; int main() { char N[100];//입력 문자열 변수 char name[20];//이름 문자열 변수 int i;//반복, 인덱스 변수 printf("간단한 채팅방에 입장하였습니다.\n"); i=0; while(1) { //문자열을 입력한다. printf("\n> "); gets(N); if(i==4) break; printf("E : %s",.. 2022. 1. 10.
C언어 96제] C언어 콘서트 CHAPTER 10 Programming 11 문자열 이어붙이기 p415 출처 : 반크_가상독도전시관 참고풀이] //Dev-C++ 5.11로 작업함. #include //sprintf() #include //strcat() #define size 5 int main() { char N[100];//입력 문자열 변수 char P[100];//결과 문자열 변수 char s[10];//정수를 문자열로 변환된 값을 저장할 변수 int i;//반복, 인덱스 변수 //문자열을 입력한다. printf("문자열을 입력하시오 : "); scanf("%s",N); //결과출력 strcpy(P,N); for(i=0;i 2022. 1. 6.
반응형