2018-07-11

0基础新人《C Primer Plus(第六版)中文版》2.12编程练习(P37-38)自敲答案整合(不保证正确)

t1:

#include

int main(void)

{

printf("Tom Jack\n");

printf("Tom \nJack \n");

printf("Tom");

printf("Jack");

getchar();

return 0;

}

t2:

#include

int main(void)

{

printf("Tom Jack \nChinaAnhui ");

getchar();

return 0;

}

t3:

#include

int main(void)

{

int age,days;

age=18;

days=age*365;/*忽略闰年*/

    printf("Age=%d岁  \nDays=%d天  ",age, days);

getchar();

return 0;

}

t4:

#include

void jolly(void);

void deny(void);

int main(void)

{

  jolly();

  deny();

  getchar();

  return 0;

}

void jolly(void)

{

  printf("For he is a jolly good fellow!\n");

  printf("For he is a jolly good fellow!\n");

  printf("For he is a jolly good fellow!\n");

}

void deny(void)

{

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

t5:

#include

void br(void);

void ic(void);

int main(void)

{

    printf("Brazil,Russia,India,China\n");

    ic();

    br();

    getchar();

    return 0;

}

void ic(void)

{

printf("India,China,\n");

}

void br(void)

{

printf("Brazil,Russia\n");

}

t6:

#include

int main(void)

{

int toes,toestwiced,toescubed;/*英语太蹩脚不知如何命名变量233*/

toes=10;

toestwiced=toes*2;

toescubed=toes^3;

printf(" toes=%d\n toestwiced=%d\n toescubed=%d\n",toes,toestwiced,toescubed);

getchar();

return 0;

}

t7:

#include

void fuck(void);/*敲这个时心情不好....函数名请忽略..*/

int main(void)

{

fuck();

fuck();

fuck();

printf(" \n");

fuck();

fuck();

printf(" \n");

fuck();

getchar();

return 0;

}

void fuck(void)

{

printf("Smile!");

}

t8:

#include

void one_three(void);

void two(void);

int main(void)

{

  printf("starting now: \n");

  one_three();

  printf("done!");

  getchar();

  return 0;

}

void one_three(void)

{

    printf("one \n");

    two();

    printf("three\n");

}

void two(void)

{

printf("two\n");

}

以上均为本人亲自敲出,没有参考其他资料,所以可能有相当程度的错误!(大概)

你可能感兴趣的:(2018-07-11)