$ gcc ex1-diamond.c $ ./a.out 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 $
$ gcc ex2-diamond.c $ ./a.out size : 4 center: 9 1 1 1 1 1 1 9 1 1 1 1 1 1 size : 5 center: 11 1 1 1 1 1 1 1 1 X 1 1 1 1 1 1 1 1 size : 3 center: 1200 1 1 1 1 C 1 1 1 1 size : 0 $
$ gcc ex3-6x6.c $ ./a.out | 1 2 3 4 5 6 ----+-------------------------- 1| 1 2 3 4 5 6 2| 2 4 6 11 13 15 3| 3 6 12 15 21 24 4| 4 11 15 22 26 33 5| 5 13 21 26 34 42 6| 6 15 24 33 42 51 $
$ gcc ex4-get-float.c $ ./a.out 123 456.23 78.1 Sum = 657.329956 <--------- ^D pressed $
$ ./a.out size : 4 border: 9 9 9 9 9 9 9 9 9 9 9 9 9 size : 3 border: 120 C C C C C C C C size : 3 border: 43 X X X X X X X X size : 0 $
void nchars(int n, char ch); /* write n 'ch' to stdout */ char convert(int n); /* convert n to a border character */And use them to complete your program. Of course, in addition to the previous two functions, you can define more functions to make your program more readable.
void rec2rad(double x, double y, double *r, double *theta); void rad2rec(double r, double theta, double *x, double *y);
$ gcc ex6-rad-rec.c -lm $ ./a.out r 3 4 (3.000000,4.000000) --> 5.000000, 0.927295 r 3 -4 (3.000000,-4.000000) --> 5.000000, -0.927295 p 5.000000 -0.927295 5.000000,-0.927295 --> (3.000001, -3.999999) p 5.000000 0.927295 5.000000,0.927295 --> (3.000001, 3.999999) q $
int read_array(int *int_array, int limit); void find_max2(int *int_array, int array_size, int &max, int &next);
$ gcc ex7-max2.c $ ./a.out 78 89 66 5433 88 The max is 5433, the next is 89 $ ./a.out 12 23 23 90 -98 The max is 90, the next is 23 $
$ cat ex8-in.dat klim 104 milk 23 redcow 88 oak 59 $ gcc ex8-fopen.c $ ./a.out input file name: ex8-in.dat output file name: ex8-out.dat $ cat ex8-out.dat klim 99 milk Fail redcow 88 oak Fail $
$ gcc ex9-grep.c $ ./a.out klim <-------- no files, read from stdin Oh, it is good. <-------- first line, ignored klim is fine. <-------- second line, contains 'klim' klim is fine. <-------- so show it Good klim <-------- third line, contains "klim' Good klim <-------- so show it milk aaaaaklimmmmmmm <-------- contains klim aaaaaklimmmmmmm <-------- so show it $ ./a.out klim ex8-in.dat ex9-grep.c <------ read from files klim 104 $ ./a.out klim ex8-in.dat ex8-out.dat <------ read from files klim 104 klim 99 $