一起来找茬
下面这段代码是让计算机在屏幕上输出绿底白字的hi。其中有4个 错误,快来改正吧!
#include <stdio.h>
#include <stdlib.h>
int main( )
{
system(color f2)
print("hi");
system("pause");
return 0;
}
修改后:#include <stdio.h>
#include <stdlib.h>
int main( )
{
system("color 2f");
printf("hi");
system("pause");
return 0;
}
更进一步,动手试一试
1.尝试让计算机打印这个小飞机图案(绿底白字)。
2.尝试让计算机打印这个小队旗图案(白底红字)。
练习:
1.
#include <stdio.h>
#include <stdlib.h>
int main( )
{
system("color 2f");
printf(" *\n");
printf(" **\n");
printf("* ***\n");
printf("** ****\n");
printf("**************\n");
printf("** ****\n");
printf("* ***\n");
printf(" **\n");
printf(" *\n");
system("pause");
return 0;
}
2.
#include <stdio.h>
#include <stdlib.h>
int main( )
{
system("color f4");
printf("A\n");
printf("I*\n");
printf("I**\n");
printf("I***\n");
printf("I****\n");
printf("I*****\n");
printf("I\n");
printf("I\n");
printf("I\n");
printf("I\n");
system("pause");
return 0;
}