목록전체 글 (313)
printf("ho_tari\n");
#include int main(void) { char c; scanf("%c", &c); int isAlphabet = ((c >= 'A' && c = 'a' && c
#include int main(void) { int man, woman; printf("Man: "); scanf("%d", &man); printf("Woman: "); scanf("%d", &woman); double manratio, womanratio; manratio = 100.0 * man / (man + woman); womanratio = 100.0 * woman / (man + woman); printf("----------------------------\n"); printf("Ratio of Man : %.2f%%\nRatio of Woman : %.2f%%\n", manratio, womanratio); return 0; } #include int main(void) { int m..
#include int gcd(int a, int b) { int remain; while ((remain = a % b) /*!= 0*/) { a = b; b = remain; } return b; } int main(void) { int a, b; printf("input 2 nums : "); scanf("%d %d", &a, &b); int result = gcd(a, b); printf("gcd(%d, %d) : %d\n", a, b, result); return 0; }
#include int main(void) { int nums[10] = {50, 90, 30, 100, 80, 10, 20, 40, 70, 60}; //initialized list int value; printf("input value : "); scanf("%d", &value); int i; for (i = 0; i < 10; ++i) { if (value == nums[i]) { break; } } if (i < 10) { printf("%d is found. index : %d\n", value, i); } else { printf("%d is not found.\n", value); } return 0; }
#include int main(void) { int nums[10] = {50, 90, 30, 100, 80, 10, 20, 40, 70, 60}; //initialized list int num; printf("input num : "); scanf("%d", &num); int find = 0; int i; for (i = 0; i < 10; ++i) { if (num == nums[i]) { find = 1; if (find == 1) { printf("%d is found. index : %d\n", num, i); } } } if (find != 1) { printf("%d is not found.\n", num); } return 0; }
#include int findMax(const int *pArr, int size) { int max; max = pArr[0]; for (int i = 1; i < size; ++i) { if (max < pArr[i]) { max = pArr[i]; } } return max; } int main(void) { int nums[] = {50, 90, 30, 100, 80, 10, 20, 40, 70, 60}; int max = findMax(nums, 10); printf("max : %d\n", max); return 0; }