C primer plus (第六版)第二章的答案

C primer plus(第六版)第二章答案

2.1

#include <stdio.h>

int main(void) {
	printf("Gustav Mahler\n"); 
	printf("Gustav\nMahler\n"); 
	printf("Gustav "); 
	printf("Mahler"); 
    
	return 0;
}

2.2

#include <stdio.h>

int main(void) {
	printf("name: joey\n"); 
	printf("address: beijing"); 
	return 0;
}

2.3

#include <stdio.h>

int main(void) {
	int age2day=365*18; 
	printf(" %d days",age2day); 

	return 0;
}

2.4

#include <stdio.h>
void jolly(void); 
void deny(void); 
int main(void) {
	jolly();
	deny(); 
	return 0;
}

void jolly(void){
	printf("For he's a jolly good fellow!\nFor he's a jolly good fellow!\nFor he's a jolly good fellow!\n"); 
} 
void deny(void){
	printf("Which nobody can deny!"); 
}

2.5

#include <stdio.h>
void br(void); 
void ic(void); 
int main(void) {
	br();
	printf(", "); 
	ic(); 
    printf("\n"); 
    ic();
    printf(",\n"); 
    br();
}

void br(void){
	printf("Brazil, Russia"); 
} 
void ic(void){
	printf("India, China"); 
}

2.6

#include <stdio.h>

int main(void) {
	int toes = 10 ;
	int double_toes=2*toes;
	int square_toes= toes*toes;
	 printf("toes:%d ; double_toes:%d ; square_toes:%d ;",toes,double_toes,square_toes); 
}

2.7

#include <stdio.h>
void smile(void); 
int main(void) {
	smile(); smile();smile();
	printf("\n");
	smile();smile();
	printf("\n");
	smile();
}
void smile(void){
    printf("Smile!");	
}

2.8

#include <stdio.h>
void one_three(void);
void two(void);
int main(void) {
	printf("starting now:\n");
	one_three();
	printf("done!");
        return 0;
}
void one_three(void){
   	printf("one\n");
   	two();
   	printf("three\n");
}
void two(void){
   	printf("two\n");
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章