作者在 2021-04-11 12:25:04 发布以下内容
2.1.c
#include <stdio.h>
int main(void) {
printf("Gustav Mahler\n");
printf("Gustav\nMahler\n");
printf("Gustav ");
printf("Mahler");
return 0;
}
2.2.c
#include <stdio.h>
int main(void) {
printf("name: Gustav Mahler\n");
printf("address: China\n");
return 0;
}
2.3.c
#include <stdio.h>
#define YEAR_PER_DAY 365
int main(void) {
int age, days;
age = 18;
days = age * YEAR_PER_DAY;
printf("age:%d\n", age);
printf("days:%d\n", days);
return 0;
}
2.4.c
#include <stdio.h>
void jolly(void);
void deny(void);
int main(void) {
jolly();
jolly();
jolly();
deny();
return 0;
}
void jolly(void) {
printf("For he's a jolly good fellow!\n");
}
void deny(void) {
printf("Which nobody can deny!\n");
}
2.5.c
#include <stdio.h>
void br(void);
void ic(void);
int main(void) {
br();
printf(", ");
ic();
printf("\n");
ic();
printf(",\n");
br();
return 0;
}
void br(void) {
printf("Brazil, Russia");
}
void ic(void) {
printf("India, China");
}
2.6.c
#include <stdio.h>
int main(void) {
int toes;
toes = 10;
printf("toes = %d\n", toes);
printf("toes * 2 = %d\n", toes * 2);
printf("toes ^ 2 = %d\n", toes * toes);
return 0;
}
2.7.c
#include <stdio.h>
void smile(void);
int main(void) {
smile();
smile();
smile();
printf("\n");
smile();
smile();
printf("\n");
smile();
printf("\n");
return 0;
}
void smile(void) {
printf("Smile!");
}
2.8.c
#include <stdio.h>
void one_three(void);
void two(void);
int main(void) {
printf("starting now:\n");
one_three();
printf("done!\n");
return 0;
}
void one_three(void) {
printf("one\n");
two();
printf("three\n");
}
void two(void) {
printf("two\n");
}