목록Career&Study/Coding Practice (15)
taeyounkim LOG
#include #define N 10 void find_two_largest(int a[], int n, int *largest, int *second_largest); int main() { int b[N], i, j; int num; printf("Enter 10 Numbers: "); for(num=0; num
#include void split_time(long total_sec, int *hr, int *min, int *sec); int main() { int i, j, k; split_time(1203, &i, &j, &k); printf("%dhrs %dmin %dsec\n", i, j, k); return 0; } void split_time(long total_sec, int *hr, int *min, int *sec) { *sec = total_sec % 60; int a = (total_sec - *sec) / 60; *min = a % 60; *hr = (a - *min) / 60; }
#include int *max(int *, int *); int main() { int *p, i=1, j=3; p = max(&i, &j); printf("%d\n", *p); return 0; } int *max(int *a, int *b) { if(*a > *b) return a; else return b; }
#include void swap(int *p, int *q); int main(void) { int i=1, j=2; swap(&i, &j); printf("%d\n", i); printf("%d\n", j); return 0; } void swap(int *p, int *q) { int temp; temp = *p; *p = *q; *q = temp; }
#include #define NUM 10 void max_min(int a[], int n, int *, int *); /*declare prototype of function*/ int main() { int array[NUM]; int big, small; printf("Enter 10 numbers: "); for(int i=0; i
#include void decompose(); int main(void) { long i; double d; decompose(3.141592, &i, &d); printf("%ld\n", i); printf("%lf", d); } void decompose(double x, long *int_part, double *frac_part) { *int_part = (long) x; *frac_part = x - *int_part; }