以下程序及结果仅供参考,如果大家有更好的方法不必拘泥于课本和答案。
1. 示例程序及结果:
#include<stdio.h>
int main()
{
printf("Gustav Mahler\n");
printf("Gustav\n");
printf("Mahler\n");
printf("Gustav") + printf(" Mahler");
}
2. 示例程序及结果:
#include<stdio.h>
int main()
{
printf("Gustav Machler,earth");
}
3. 示例程序及结果:
#include<stdio.h>
int main(void)
{
int ages;
int days;
ages=20;
days=365*ages;
printf("I am %d years old,which is %d days.\n",ages,days);
return 0;
}
4. 示例程序及结果:
#include<stdio.h>
void jolly(void);
void deny(void);
int main(void)
{
jolly();
deny();
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");
}
5. 示例程序及结果:
#include<stdio.h>
void br(void);
void ic(void);
int main(void)
{
br();printf(",");ic();
ic();
br();
return 0;
}
void br(void)
{
printf("Brazil,Russia");
}
void ic(void)
{
printf("India,China\n");
}
6. 示例程序及结果:
#include<stdio.h>
int main(void)
{
int toes,toes2,toes_2;
toes=10;
toes2=toes*2; //toes的两倍//
toes_2=toes*toes; //toes的平方//
printf("toes is %d\n",toes);
printf("toes*2 is %d\n",toes2);
printf("toes^2 is %d\n",toes_2);
return 0;
}
7. 示例程序及结果:
#include<stdio.h>
void smile(void);
int main()
{
smile();smile();smile();printf("\n");
smile();smile();printf("\n");
smile();printf("\n");
return 0;
}
void smile(void)
{
printf("Smile!");
}
8. 示例程序及结果:
#include<stdio.h>
void one_three(void);
int main()
{
printf("Starting now:\n");
one_three();
printf("done!\n");
return 0;
}
void two(void);
void one_three(void)
{
printf("one\n");
two();
printf("three\n");
}
void two(void)
{
printf("two\n");
}