1.思维导图
2.shell函数获取uid和gid,并用变量接
#!/bin/bashfunction fun()
{read -p "输入用户名" necho uid:`id -u $n`echo gid:`id -g $n`
}
a=`fun`
echo $a
3.冒泡、选择和快排代码整理
/*************************************************************************> File Name: zy2.c> Created Time: 2023年08月07日 星期一 18时58分10秒************************************************************************/#include <myhead.h>int one_sort(int arr[], int low, int high)
{int key=arr[low];while (low < high){while (low<high && key<=arr[high])high--;arr[low]=arr[high];while (low<high && key>=arr[low])low++;arr[high]=arr[low];}//low=higharr[low]=key;return low;
}void quick_short(int arr[], int low, int high)
{if (low >= high){return;}//一轮排序int mid=one_sort(arr, low, high);quick_short(arr, low, mid-1);quick_short(arr, mid+1, high);
}int main(int argc, char *argv[])
{//确定数组大小int n;printf("请输入元素个数:");scanf("%d", &n);//定义数组int arr[n];//循环输入元素for (int i=0; i<n; i++){printf("输入第%d个元素:", i);scanf("%d", &arr[i]);}// //冒泡排序// for (int i=1; i<n; i++) // {// int count=0;// for (int j=0; j<n-i; j++)// {// if (arr[j] > arr[j+1])// {// int temp=arr[j];// arr[j]=arr[j+1];// arr[j+1]=temp;// count++;// }// }// if (count == 0)// break;// }// //简单选择排序// for (int i=0; i<n-1; i++)// {// int min=i;// for (int j=i+1; j<n; j++)// {// if (arr[min] > arr[j])// min=j;// if (min != i)// {// int temp=arr[i];// arr[i]=arr[min];// arr[min]=temp;// }// }// }//快速排序quick_short(arr, 0, n-1);//循环输出元素for (int i=0; i<n; i++){printf("%-3d", arr[i]);}putchar(10);return 0;
}