Ubuntu19.10 comes with gcc, if you don’t have one, install the gcc compiler first:
sudo apt install build-essential
Create a C language program file:
vim Hello.c
Enter the code, whatever you want, just run it:
# include <stdio.h>
# include <math.h>
int main(){for( float y =1.3; y >=-1.1; y -=0.06){for( float x =-1.2; x <=1.2; x +=0.025){if(pow((x*x+y*y-1.0),3)- x*x*y*y*y <=0.0)printf(" ");elseprintf("*");}printf("\n");}return0;}
Next compile the file:
gcc -o Hello Hello.c -lm
- o
is to determine the name of the output file, the first Hello is the name of the output file, which can be customized.
- The lm
option tells the compiler that the mathematical functions used in our program should be found in this library file.
Attach the meaning of commonly used parameters:
lc is link libc
lm is link libm
lz is link libz
After the compilation is complete, enter the execution command:
. /Hello
Can output:
Recommended Posts