#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include<stdlib.h>
int main()
{
int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int k = 6;
int se = sizeof (arr) / sizeof (arr[0]);
int left = 0;
int right = se - 1;
while (left <= right)
{
int mid = (left + right) / 2;
if (arr[mid] > k)
{
right = mid - 1;
}
else if (arr[mid] < k)
{
left = mid + 1;
}
else
{
printf("找到了,下标是 %d\n", mid);
break;
}
}
if (left>right)
{
printf("找不到\n");
}
return 0;
}
int main()
{
int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int b = 4;
int i = 0;
int se = sizeof (arr) / sizeof (arr[0]);
for (i = 0; i < se;i++)
{
if (b == arr[i])
{
printf("找到了,下标是 %d\n", i);
break;
}
}
return 0;
}
int main()
{
int i = 0;
int n = 0;
int ret = 1;
int sum = 0;
for (n = 1; n <= 7; n++)
{
ret = ret * n;
sum = sum + ret;
}
printf("sum = %d\n", sum);
return 0;
}
int main()
{
int i = 0;
int n = 0;
int sum = 0;
for (n = 1; n <=7; n++)
{
int ret = 1;
for (i=1; i<=n; i++)
{
ret = ret * i;
}
sum = sum + ret;
}
printf("sum = %d\n", sum);
return 0;
}
int main()
{
int i = 0;
int n = 0;
int ret = 1;
scanf("%d", &n);
for(i = 1; i<=n; i++)
{
ret = ret * i;
}
printf("ret = %d\n", ret);
return 0;
}
int main()
{
char arr1[] = { "welconme to 71231!!!!!!!"};
char arr2[] = { "########################" };
int left = 0;
int right = sizeof(arr1) / sizeof(arr1[0])-2;//实际是 welcome to 71231!!!!!!!\0 多了第一个\0和初始的下标0 so 减2
while (left<= right)
{
arr2[left] = arr1[left];
arr2[right] = arr1[right];
left++;
right--;
Sleep(800);
system("cls");
printf("%s\n", arr2);
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////int main()
////{
////
//// char accounts[] = {0};
//// char password[] = {0};
//// int i = 0;
//// printf("请输入账号:>");
//// scanf("%s", accounts);
//// (strcmp(accounts, "1234") == 0);
//// for (i = 1; i <= 3;i++)
//// {
//// printf("请输入密码:>");
//// scanf("%s", password);
//// if (strcmp(password, "z12345") == 0)//==不能用来比较两个字符串是否相等,应该使用一个库函数-strcmp
//// {
//// printf("登陆成功\n");
//// break;
//// }
//// else
//// {
//// printf("账号或者密码输入错误\n");
//// }
//// if (i == 3)
//// {
//// printf("三次均错误,账号已冻结\n");
//// }
//// }
//// return 0;
////}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main()
{
int a = 0;
int b = 0;
int c = 0;
scanf("%d%d%d", &a, &b, &c);
if (a < b)
{
int tmp = a;
a = b;
b = tmp;
}
if (a < c)
{
int tmp = a;
a = c;
c = tmp;
}
if (b < c)
{
int tmp = b;
b = c;
c = tmp;
}
printf("%d %d %d\n", a, b, c);
return 0;
}
int main()
{
int a = 44;
int b = 34;
int r = 0;
scanf("%d%d", &a, &b);
while (r = a%b)
{
r = a % b;
a = b;
b = r;
}
printf("%d\n", b);
return 0;
}
标签:tmp,10,arr,main,所学,int,printf,return,分享
From: https://blog.51cto.com/u_16182079/6681988