Instantly share code, notes, and snippets.

HyeonWooKim/gist:ecfe308a702c4a0fa333

Created February 26, 2016 17:53
Show Gist options
• Save HyeonWooKim/ecfe308a702c4a0fa333 to your computer and use it in GitHub Desktop.
실전 C프로그래밍 문제모음
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /************************************** 국민대학교 컴퓨터공학부 20103324 김현우 문제 8 : 시간 계산 ***************************************/ #include #include #include using namespace std; void main(void) { ifstream inStream; int numTestCases; inStream.open("input.txt"); if(inStream.fail()) { cerr << "Input file opening failed\n"; exit(1); } inStream >> numTestCases; for(int i=0; i> people; for(int j=0; j> H >> M >> S >> h >> m >> s; result+=(h*3600+m*60+s)-(H*3600+M*60+S); } w=result/86400; result%=86400; o=result/3600; result%=3600; r=result/60; result%=60; k=result; cout << w << " " << o << " " << r << " " << k << "\n"; } inStream.close(); }
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /************************************** 국민대학교 컴퓨터공학부 20103324 김현우 문제 9 : 주어진 정수의 최대, 최소 구하기 ***************************************/ #include #include #include using namespace std; int getNum(int num1, int num2, bool isgetmax); void main(void) { ifstream inStream; int numTestCases; inStream.open("input.txt"); if(inStream.fail()) { cerr << "Input file opening failed\n"; exit(1); } inStream >> numTestCases; for(int i=0; i> count >> val; min=max=val; for(int j=1; j> val; max = getNum(val, max, true); min = getNum(val, min, false); } cout << max << " " << min << "\n"; } inStream.close(); } int getNum(int num1, int num2, bool ismax) { if(ismax) return num1>=num2?num1:num2; else return num1<=num2?num1:num2; }
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /************************************** 국민대학교 컴퓨터공학부 20103324 김현우 문제 10 : 숫자로 삼각형 출력하기 ***************************************/ #include #include #include using namespace std; void drawTriangle(int size); void main(void) { ifstream inStream; int numTestCases; inStream.open("input.txt"); if(inStream.fail()) { cerr << "Input file opening failed\n"; exit(1); } inStream >> numTestCases; for(int i=0; i> sizeOfTriangle; drawTriangle(sizeOfTriangle); } inStream.close(); } void drawTriangle(int size) { for(int i=1; i<=size; i++) { int temp1=size, temp2=i; cout << temp2 << " "; for(int j=1; j
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /************************************** 국민대학교 컴퓨터공학부 20103324 김현우 문제 12 : 다이아몬드 모양 출력하기 ***************************************/ #include #include #include using namespace std; void drawDiamond(int size); void main(void) { ifstream inStream; int numTestCases; inStream.open("input.txt"); if(inStream.fail()) { cerr << "Input file opening failed\n"; exit(1); } inStream >> numTestCases; for(int i=0; i> sizeOfTriangle; drawDiamond(sizeOfTriangle); } inStream.close(); } void drawDiamond(int size) { int temp1=size/2+1, temp2=1, k=1; for(int i=1; i<=size; i++) { k=1; while(k++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /************************************** 국민대학교 컴퓨터공학부 20103324 김현우 문제 12 : 모래시계 출력하기 ***************************************/ #include #include #include using namespace std; void drawHourGlass(int size); void main(void) { ifstream inStream; int numTestCases; inStream.open("input.txt"); if(inStream.fail()) { cerr << "Input file opening failed\n"; exit(1); } inStream >> numTestCases; for(int i=0; i> sizeOfTriangle; drawHourGlass(sizeOfTriangle); } inStream.close(); } void drawHourGlass(int size) { int temp1=0, temp2=size; for(int i=1; i<=size; i++) { int k=0; while(k++
to join this conversation on GitHub. Already have an account? Sign in to comment