#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<windows.h>
#include<stdlib.h>
int main()
{
/*int a = 0;
int b = 0;
int c = 1;
int d = 1;
scanf("%d", &b);
for (a = 1; c < b; ++c)
{
d = d + 1;
a = a * d;
printf("%d ", a);
}
return 0;*/
/*int i = 0;
int n = 0;
int ret = 1;
int sum = 0;
int a = 0;
scanf("%d", &a);
for (n = 1; n <= a; n++)
{
ret = 1;
for (i = 1; i <= n; i++)
{
ret = ret * i;
}
sum = sum + ret;
}*/
/*int i = 0;
int n = 0;
int ret = 1;
int sum = 0;
int a = 0;
scanf("%d", &a);
for (i = 1;i <= a; i++)
{
ret = ret * i;
sum = sum + ret;
printf("%d ", sum);
}*/
//int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
//int i = 0;
//int k = 7;
//int sz = sizeof(arr) / sizeof(arr[0]);//数组元素的个数
////sizeof表示数据类型或变量所占空间的大小。
//for (i = 0; i < sz; i++)
//{
// if (k == arr[i])
// {
// printf("找到了,下标是%d\n",i);
// break;
// }
//}
//if (i == sz)
//{
// printf("找不到");
//}
//return 0;
//折半查找算法、二分查找算法
/*int k = 0;
int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
int sz = sizeof(arr) / sizeof(arr[0]);
int left = 0;
int right = sz-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", mid);
break;
}
}
if (left > right)
{
printf("找不到\n");
}
return 0;*/
//char arr1[] = "welcome to bit!!!!!!";
//char arr2[] = "####################";
//int left = 0;
//int right = strlen(arr1) - 1;
//while (left <= right)
//{
// arr2[left] = arr1[left];
// arr2[right] = arr1[right];
// printf("%s\n", arr2);
// Sleep(1000);//休息一秒 1000ms #include<windows.h>
// system("cls");//执行系统命令的一个函数-cls-,清空屏幕 #include<stdlib.h>
// left++;
// right--;
//}
//return 0;
int i = 0;
char password[20] = { 0 };
for (i = 0; i < 3; i++);
{
printf("请输入密码:>");
scanf("%s", password);
if (strcmp(password, "123456") == 0)//==不能用来比较两个字符串是否相等,应该使用一个库函数-strcmp
{
prinf("登陆成功\n");
break;
}
else
{
printf("密码错误\n");
}
}
if (i == 3)
{
printf("三次密码均错误,退出程序\n");
}
return 0;
}
这是今天学习写的代码
标签:right,第一天,int,第四天,mid,博客,printf,include,left From: https://blog.51cto.com/u_16224270/7235266