# 最近写的小程序

\\求十个数中的最大最小值
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int n[10];
int i = 0, max = 0, min = 0;
int count1 = 0, count2 = 0;
printf("输入十个数\n");
for (i = 0; i <= 9; i++)
{
scanf("%d", &n[i]);
}
max = n[0];
min = n[0];
for (i= 0; i < 9; i++)
{
if (max < n[i + 1])
{
max = n[i + 1];
count1=i+1;
}
}
printf("最大数为%d，为n[%d]\n",max, count1);
for (i = 0; i < 9; i++)
{
if (min>n[i + 1])
{
min = n[i + 1];
count2=i+1;
}
}
printf("最小数为%d，为n[%d]", min, count2);
system("pause");
return 0;

}

\\1,2,3,4组成的三位数
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int i, j, k;
int n = 0;
for (i = 1; i<5; i++)
for (j = 1; j<5; j++)
for (k = 1; k<5; k++)
if (i != j&&i != k&&j != k)
{
n++;
printf("%d%d%d ", i, j, k);
if (n % 4 == 0)
printf("\n");
}
printf("\nTotal number:%d\n", n）;

system("pause");
return 0;
}


\\交换数组
#include<stdio.h>
#include<windows.h>

int main()
{
int i;
int a[10] = { 0 };
int b[10] = { 0 };
int t[10] = { 0 };
printf("输入数组a和数组b\n");
for (i = 0; i < 10; i++)
{
scanf_s("%d", &a[i]);
}
for (i = 0; i < 10; i++)
{
scanf_s("%d", &b[i]);
}

for (i = 0; i < 10; i++)
{
t[i] = a[i];
a[i] = b[i];
b[i] = t[i];
}
for (i = 0; i < 10; i++)
{
printf(" %d", a[i]);
}
for (i = 0; i < 10; i++)
{
printf(" %d", b[i]);
}
system("pause");
return 0;
}

\\输出十进制数的二进制1和0的序列
#include<stdio.h>
#include<windows.h>

int main()
{
int n = 0,i=0,x=0,y=0;
int a[32] = { 0 };
int b[32] = { 0 };
printf("输入十进制数\n");
scanf_s("%d", &n);
while (n)
{
i++;
n = n&(n - 1);
}
printf("%d\n", i);

for (x = 0; x < i; x++)
{
a[x] = 1;
printf("%d", a[x]);
}
printf("\n");
for (y = 0; y< 32 - i; y++)
{
b[x] = 0;
printf("%d", b[x]);
}

system("pause");
return 0;
}

//从大到小输出三个数
#include<stdio.h>
#include<windows.h>

int main()
{
int a = 0, b = 0, c = 0,t=0;
printf("输入a，b，c的值\n");
scanf_s("%d%d%d", &a, &b, &c);
if (a < b)
{
t = a;
a = b;
b = t;
}
if (a < c)
{
t = a;
a = c;
c = t;
}
if (b < c)
{
t = b;
b = c;
c = t;
}
printf("%d %d %d", a, b, c);
system("pause");
return 0;
}

\\最大公约数
#include<stdio.h>
#include<windows.h>

int main()
{
int a = 0, b = 0, n = 0;
int num = 0;
printf("输入两个数\n");
scanf_s("%d%d", &a, &b);
if (a < b)
{
int t = a;
a = b;
b = t;
}
for (n = b; n >0; n--)
{
if ((a%n == 0) && (b%n == 0))
{
num = n;
break;
}
}
printf("%d", num);
system("pause");
return 0;
}