1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <stdio.h>
int f(int n) {
int time_ran = 0;
for( int i = 0; i < n; i++ ) {
for( int j = 0; j < n; j++ ) {
printf( "ABC" );
time_ran++;
}
}
return time_ran;
}
int g(int n) {
int time_ran = 0;
for( int j = 0; j < n; j++ ) {
printf( "ABCDEFGHIJKLMNOP" );
time_ran++;
}
return time_ran;
}
int main(int argc, const char *argv[]) {
printf("--------------------\n");
int time_ran = f(10);
printf("f(..) ran %d times\n--------------------\n", time_ran);
time_ran = g(10);
printf("g(..) ran %d times\n--------------------\n", time_ran);
return 0;
}
|
© Copyright 2016 Alexander J. Quinn This content is protected and may not be shared, uploaded, or distributed.