完成习题7
This commit is contained in:
parent
0ebac484e7
commit
dbad3999ba
|
@ -9,11 +9,13 @@ int main(int argc, char *argv[])
|
|||
char first_name[] = "Zed";
|
||||
char last_name[] = "Shaw";
|
||||
|
||||
// first_name[4] = '@';
|
||||
|
||||
printf("You are %d miles away.\n", distance);
|
||||
printf("You have %f levels of power.\n", power);
|
||||
printf("You have %f awesome super powers.\n");
|
||||
printf("You have %f awesome super powers.\n", super_power);
|
||||
printf("I have an initial %c.\n", initial);
|
||||
printf("I have a first name %s.\n", first_name);
|
||||
printf("I have a first name %s.\n", first_name + 10000);
|
||||
printf("I have a last name %s.\n", last_name);
|
||||
printf("My whole name is %s %c. %s.\n", first_name, initial, last_name);
|
||||
|
||||
|
@ -22,7 +24,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
printf("You have %d bugs at the imaginary rate of %f.\n", bugs, bug_rate);
|
||||
|
||||
long universe_of_defects = 1L * 1024L * 1024L * 1024L;
|
||||
unsigned long universe_of_defects = 1100000999999L * 1024L * 1024L * 1024L;
|
||||
|
||||
printf("The entire universe has %ld bugs.\n", universe_of_defects);
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int distance = 100;
|
||||
float power = 2.345f;
|
||||
double super_power = 56789.4532;
|
||||
char initial = 'A';
|
||||
char first_name[] = "Zed";
|
||||
char last_name[] = "Shaw";
|
||||
|
||||
printf("You are %d miles away.\n", distance);
|
||||
printf("You have %f levels of power.\n", power);
|
||||
printf("You have %f awesome super powers.\n");
|
||||
printf("I have an initial %c.\n", initial);
|
||||
printf("I have a first name %s.\n", first_name);
|
||||
printf("I have a last name %s.\n", last_name);
|
||||
printf("My whole name is %s %c. %s.\n", first_name, initial, last_name);
|
||||
|
||||
int bugs = 100;
|
||||
double bug_rate = 1.2;
|
||||
|
||||
printf("You have %d bugs at the imaginary rate of %f.\n", bugs, bug_rate);
|
||||
|
||||
long universe_of_defects = 1L * 1024L * 1024L * 1024L;
|
||||
|
||||
printf("The entire universe has %ld bugs.\n", universe_of_defects);
|
||||
|
||||
double expected_bugs = bugs * bug_rate;
|
||||
|
||||
printf("You are expected to have %f bugs.\n", expected_bugs);
|
||||
|
||||
double part_of_universe = expected_bugs / universe_of_defects;
|
||||
|
||||
printf("That is only a %e portion of the universe.\n", part_of_universe);
|
||||
|
||||
// this makes no sense, just a demo of something weird
|
||||
char nul_byte = '\0';
|
||||
int care_percentage = bugs * nul_byte;
|
||||
|
||||
printf("Which means you should care %d%%.\n", care_percentage);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue