如何在ubuntu上写一个类似sl跑火车指令,“跑甜甜圈”
生活随笔
收集整理的這篇文章主要介紹了
如何在ubuntu上写一个类似sl跑火车指令,“跑甜甜圈”
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
如何在ubuntu上寫一個類似sl跑火車指令,“跑甜甜圈”
首先創建.c文件
#include <stdio.h> #include <math.h> #include <string.h> #include <unistd.h>int main() {float A = 0, B = 0;float i, j;int k;float z[1760]; //array to store particular value wjhich will be used for creating the shadown/back image of the doughnutchar b[1760]; //array of characters to stor the components that will make up the doughnutprintf("\x1b[2J");for (;;) {memset(b, 32, 1760);memset(z, 0, 7040);for (j = 0; j < 6.28; j += 0.07) {for (i = 0; i < 6.28; i += 0.02) {float c = sin(i);float d = cos(j);float e = sin(A);float f = sin(j);float g = cos(A);float h = d + 2;float D = 1 / (c * h * e + f * g + 5);float l = cos(i);float m = cos(B);float n = sin(B);float t = c * h * g - f * e;int x = 40 + 30 * D * (l * h * m - t * n);int y = 12 + 15 * D * (l * h * n + t * m);int o = x + 80 * y;int N = 8 * ((f * e - c * d * g) * m - c * d * e - f * g - l * d * n);if (22 > y && y > 0 && x > 0 && 80 > x && D > z[o]) {z[o] = D;b[o] = ".,-~:;=!*#$@"[N > 0 ? N : 0];}}}printf("\x1b[H");for (k = 0; k < 1761; k++) {putchar(k % 80 ? b[k] : 10);A += 0.00004; // This defines the speed at which the doughnut will be rotating on 2D axisB += 0.00002; // This will determine the rotation on t5he 3rd axis }usleep(100000); //used for time delay}return 0; }將文件保存到一個你知道的路徑,并且進行編譯。
gcc ttq.c -lm -o ttq因為用來math.h所以要加一個-lm來鏈接庫,不然會報錯。
接下來就是自定義命令,當然也可以直接調用可執行文件,但需要在指定目錄下或者在終端輸入目錄,不是很方便。
在.alias中加入你所要自定義的命令
sudo vim /home/.alias sudo vim /home/.bashrc加入如下代碼,使你的自定義名生效
# Aliases if [ -f ~/.alias ]; then. ~/.alias fi source /home/.alias source /home/.bashrc最后在任何路徑下輸入,你所定義的命令就可以看到一個‘跑’起來的甜甜圈
總結
以上是生活随笔為你收集整理的如何在ubuntu上写一个类似sl跑火车指令,“跑甜甜圈”的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html5ppt介绍,html5介绍.p
- 下一篇: E3 V5 和Rme声卡不兼容