Skip to content

Instantly share code, notes, and snippets.

View henrybear327's full-sized avatar

Chun-Hung Tseng henrybear327

View GitHub Profile
@henrybear327
henrybear327 / print a diamond using 8 for loops.c
Last active August 29, 2015 14:07
CCU programming course bonus question 1 solution 1
#include<stdio.h>
int main()
{
int current_row, total_upper_row, star, space;
printf("Please enter a number: ");
scanf("%d", &total_upper_row);
for(current_row = 1; current_row <= total_upper_row; current_row++)
{
for(star = total_upper_row - current_row + 1; star >= 1; star--)
@henrybear327
henrybear327 / print a diamond using 2 for loops.c
Last active August 29, 2015 14:07
CCU programming course bonus question 1 solution 2
#include <stdio.h>
#include <stdlib.h>
int main()
{
char str1[] = "********************************************";
char str2[] = " ";
int space = 1, star, total;
scanf("%d", &star);
@henrybear327
henrybear327 / Week 4 pc^2 project.c
Last active August 29, 2015 14:07
Week 4 pc^2 project
#include <stdio.h>
#include <stdlib.h>
int main()
{
int bars, coupon;
while(scanf("%d", &bars) != EOF)
{
coupon = bars;
@henrybear327
henrybear327 / print a diamond using 1 for loop.c
Created October 11, 2014 04:43
print a diamond using 1 for loop.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
char str1[] = "********************************************";
char str2[] = " ";
int space = 1, star, initial_star;
scanf("%d", &star);
@henrybear327
henrybear327 / UVA100.c
Last active August 29, 2015 14:07
UVA100.c
/*
READ THE QUESTIONS CAREFULLY!
EVERY WORD REGARDING ALGORITHM, INPUT, OUTPUT, ETC. MUST BE CAREFULLY READ AND FOLLOWED.
eg. Think of swapping the input; be cautious on the output format!!!
What the statements said in the questions count, not my personal judgement!
The f****** "output order must be the same as input" statement caught me off guard TWICE! Learn the lesson.
*/
#include <stdio.h>
#include <stdlib.h>
@henrybear327
henrybear327 / ACM10055(normal).c
Last active August 29, 2015 14:07
ACM10055(normal).c
#include <stdio.h>
#include <stdlib.h>
/*
ACM doesn't take %I64d\n, they take %lld\n only.
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=12&problem=996&mosmsg=Submission+received+with+ID+14345306
*/
int main()
{
@henrybear327
henrybear327 / ACM10499.c
Last active August 29, 2015 14:07
ACM10499.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
long long int equal_parts;
while(scanf("%lld", &equal_parts) != EOF)
{
if(equal_parts < 0)
break;
@henrybear327
henrybear327 / ACM10055(one line).c
Last active August 29, 2015 14:07
ACM10055(one line).c
#include<stdio.h>
int main()
{
long long int input_1 = 0, input_2 = 0;
while(scanf("%lld %lld", &input_1, &input_2) != EOF)
printf("%lld\n", (input_1 - input_2 >= 0) ? input_1 - input_2 : input_2 - input_1);
return 0;
}
@henrybear327
henrybear327 / ACM10812.c
Last active August 29, 2015 14:07
ACM10812.c
#include <stdio.h>
#include <stdlib.h>
/*
http://uva.onlinejudge.org/index.php?option=onlinejudge&Itemid=99999999&page=show_problem&category=&problem=1753&mosmsg=Submission+received+with+ID+14388286
*/
int main()
{
@henrybear327
henrybear327 / ACM10812(using for).c
Last active August 29, 2015 14:07
ACM10812(using for).c
#include <stdio.h>
#include <stdlib.h>
/*
http://uva.onlinejudge.org/index.php?option=onlinejudge&Itemid=99999999&page=show_problem&category=&problem=1753&mosmsg=Submission+received+with+ID+14388286
*/
int main()
{
int total_cases, count = 0, input_1, input_2;
scanf("%d", &total_cases);