목록C (66)
printf("ho_tari\n");
#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; }
#include int main(void) { int fahr; int celsius; fahr = 100; //celsius = 5/9 * (fahr - 32); //celsius = 5.0 / 9.0 * (fahr - 32); celsius = (fahr - 32) * 5/9; printf("fahr : %d ---> celsius : %d\n", fahr, celsius); return 0; } #include int main(void) { int fahr; double celsius; printf("Fahrenheit : "); scanf("%d", &fahr); celsius = 5.0 / 9.0 * (fahr - 32); printf("Celsius : %.3f\n", celsius); ret..
#include long long factorial(int n) { long long result = 1LL; for (int i = 2; i
#include #include #include int main(void) { srand(time(NULL)); // seed for (int i = 1; i
#include int main(void) { int a, b; printf("input 2 nums : "); scanf("%d %d", &a, &b); printf("%d > %d : %d\n", a, b, a > b); printf("%d = %d : %d\n", a, b, a >= b); printf("%d