编写Hello World脚本
语言: Bash
代码:
```bash
!/bin/bash
echo "Hello World!"
```
通过位置变量创建Linux系统账户及密码
语言: Bash
代码:
```bash
!/bin/bash
useradd "$1"
echo "$2" | passwd -stdin "$1"
```
备份日志
语言: Bash
代码:
```bash
!/bin/bash
tar -czf log-$(date +%Y%m%d).tar.gz /var/log
```
一键部署LNMP(RPM包版本)
语言: Bash
代码:
```bash
!/bin/bash
yum -y install httpdyum mariadb mariadb-devel mariadb-server
```
C语言趣味编程100例
语言: C
代码:
```c
include int main() { int a, b, c, i = 0; for (a = 1; a <= 5; a++) for (b = 1; b <= 5; b++) for (c = 1; c <= 5; c++) if (a != b && a != c && c != b) i++; printf("A,B,C三人所选书号分别为:\n"); for (a = 1; a <= 5; a++) for (b = 1; b <= 5; b++) for (c = 1; c <= 5; c++) if (a != b && a != c && c != b) printf("%d,%d,%d\n", a, b, c); return 0; } ``` 由1,2,3,4个数字组成的三位数 语言: C++ 代码: ```cpp include using namespace std; int main() { int n = 4 * 3 * 2; cout << "由1,2,3,4个数字,能组成"<< n << "个互不相同且无重复数字的三位数!" << endl; return 0; } ``` 企业奖金提成计算 语言: C++ 代码: ```cpp include using namespace std; int main() { long long I, bonus; cout << "请输入当月利润I(万元): "; cin >> I; if (I <= 10) bonus = I * 0.1; else if (I <= 20) bonus = 10 + (I - 10) * 0.075; else if (I <= 40) bonus = 30 + (I - 20) * 0.05; else if (I <= 60) bonus = 50 + (I - 40) * 0.03; else if (I <= 100) bonus = 70 + (I - 60) * 0.015; else bonus = 100 + (I - 100) * 0.01; cout << "应发放奖金总数为: " << bonus << "万元" << endl; return 0; } ``` 这些示例涵盖了从简单的Hello World脚本到复杂的奖金提成计算程序,帮助你在电脑上进行编程实践。建议从简单的示例开始,逐步掌握编程的基本概念和技巧,然后逐步尝试更复杂的项目。