《C Primer Plus》(第6版)中文版 课后练习题 - Chapter 2


practise 1 --------------- #include <stdio.h> int main(void) { printf("Gustav Mahler\n"); //一开始我这里使用单引号一直报错,后来改成了双引号才成功 printf("Gstav\n"); printf("Mahler\n"); printf("Guster Mahler\n"); return 0; }
practise 2
---------------
#include <stdio.h>
int main(void)
{
	printf("我叫超\n");
	printf("我来自美丽的连云港\n");
	return 0;
 } 

  

practise 3
---------------
#include <stdio.h>
int main(void)
{
	int a,b;
	a = 27 ; 
	b = a * 365;
	printf("我今年%d岁了,出生%d天了",a,b);
	return 0; 
}

  

practise 4
---------------
#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");//子函数里不能有 return 0字样
 }

void deny(void)
{
	printf("Which nobody can deny!\n");
}

  

practise 5
---------------
#include <stdio.h>
void br(void);
void ic(void);
int main(void)

{
	br();
	ic();
	ic();
	br();
	return 0;
}

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

void ic()
{
	printf("India,China\n");
}

  

practise 6
---------------
#include <stdio.h>
int main(void)
{
	int toes,toes2,toes_2;
	toes  = 10;
	toes2 = toes * 2;
	toes_2= toes * toes;
	printf("toes = %d ;\ntoes2 = %d;\ntoes_2 = %d.\n",toes,toes2,toes_2);
	return 0;
}

  

practise 7
---------------
#include <stdio.h>
void wang(void);//函数原型 
int main(void)
{
	wang();wang();wang();printf("\n");//我真是太机智了 
	wang();wang();printf("\n");
	wang();
	
	return 0;
 } 
 
void wang(void)
{
	printf("Smile!");
}

  

practise 8
---------------
#include <stdio.h>
void one_three(void);
void two(void);
int main (void) 
{
	printf("Starting now:\n");
	one_three();
	printf("two\n");
	two();
	printf("done!\n");
	return 0;
}

void one_three(void)
{
	printf("one\n");
}
void two(void)
{
	printf("three\n");
}

  

这些都是我自己写的,希望对你们有所帮助。
 

猜你喜欢

转载自www.cnblogs.com/dachaozi/p/12711468.html