//环境:VS2019
#include<stdio.h>
//example 1
int main(void)
{
printf("Ming Wang\n");
printf("Ming\nWang\n");
printf("Ming Wang\n");
return 0;
}
//----------------------------------------------------------------
//example2
int main(void)
{
printf("Wang Ming\n");
printf("JiLin,China\n");
return 0;
}
//----------------------------------------------------------------
//example3
#define year_to_day 365
int main(void)
{
int ages;
printf("请输入你的年龄:\n");
scanf_s("%d", &ages); //闰年考虑不了
printf("你的年龄对应着%d天\n", ages * year_to_day);
return 0;
}
//----------------------------------------------------------------
//example4
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");
}
//----------------------------------------------------------------
//example5
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");
}
//----------------------------------------------------------------
//example6
int main(void)
{
int toes;
toes = 10;
printf("toes是%d,toes的两倍是%d,toes的平方是%d", toes, toes * 2, toes * toes);
return 0;
}
//----------------------------------------------------------------
//example7
void Smile(void);
int main(void)
{
Smile();
Smile();
Smile();
printf("\n");
Smile();
Smile();
printf("\n");
Smile();
return 0;
}
void Smile(void)
{
printf("Smile!");
}
//----------------------------------------------------------------
//example8
void one_three(void);
void two(void);
int main(void)
{
printf("starting now:\n");
one_three();
printf("\n");
two();
printf("\n");
printf("three\n");
printf("done!\n");
return 0;
}
void one_three(void)
{
printf("one");
}
void two(void)
{
printf("two");
}
//----------------------------------------------------------------
//end
C Primer Plus第六版第二章编程练习答案
最新推荐文章于 2020-12-01 23:53:21 发布