#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
//
//////
////
////int main()
////{
//// double d = 3.14;
//// double* pd = &d;
//// printf("%d\n", sizeof(pd));
//// return 0;
////
////}
////int main()
////{
//// int a = 0;
//// return 0;
////
////}
////int main()
////{
//// int age = 20;
//// if (age < 18)
//// printf("未成年\n");
//// else
//// printf("成年\n");
////
//// return 0;
////
////}
////int main()
////{
//// int age =65 ;
//// if (age < 18)
//// printf("未成年\n");
//// else if ( age < 28)
//// printf("青年\n");
//// else if ( age < 50)
//// printf("壮年\n");
//// else if ( age < 90)
//// printf("老年\n");
//// else
//// printf("长寿\n");
//// return 0;
////}
////int main()
////{
//// int a = 0;
//// int b = 2;
//// if (a == 1)
//// if (b == 2)
//// printf("hehe\n");
//// else
//// printf("haha\n");
//// return 0;
////}
////int main()
////{
//// int num = 4;
//// if (num == 5)
//// {
//// printf("hehe\n");
////
//// }
////
//// return 0;
////}
////int main()
////{
//// int i = 1;
//// while (i <= 100)
//// {
//// if (i%2 ==1)
//// printf("%d ",i);
//// i++;
//// }
//// return 0;
////}
////int main()
////{
//// int day = 0;
//// scanf("%d", &day);
//// switch(day)
//// {
//// case 1:
//// case 2:
//// case 3:
//// case 4:
//// case 5:
//// printf("工作日");
//// break;
//// case 6:
//// case 7:
//// printf("休息日");
//// break;
//// default :
//// printf("输入错误");
//// break;
////
//// }
//
////int main()
////{
//// int n = 1;
//// int m = 2;
//// switch (n)
//// {
//// case 1:m++;
//// case 2:n++;
//// case 3:
//// switch (n)
//// {
//// case 1:n++;
//// case 2:m++; n++; break;
////
////
//// }
//// case 4:m++;
//// break;
//// default:
//// break;
//// }
//// printf("n=%d m=%d", n, m);
////
//// return 0;
////}
//
////int main()
////{
//// int i = 1;
//// while (i <= 10)
//// {
//// if (5 == i)
//// break;
//// printf("%d ", i);
//// i++;
//// }
//// return 0;
//////}
////int main()
////{
//// int ch = 0;
//// while((ch=getchar())!=EOF)
//// {
//// putchar(ch);
//// }
//// return 0;
////}
////int main()
////{
//// return 0;
////}
////int main()
////{
//// return 0;
////}
////int main()
////{
//// return 0;
////
////}
////int main()
////{
//// return 0;
////
////
////}
////int main()
////{
//// return 0;
////}
////int main()
////{
//// return 0;
////
////}
////int main()
////{
//// return 0;
////}
////int main()
////{
//// return 0;
////int main()
////{
//// int ch = 0;
//// int ret = 0;
//// char password[20] = { 0 };
//// printf("请输入秘密:>");
//// scanf("%s", password);
//// while ((ch = getchar())!= '\n');
//// {
//// ;
//// }
//// printf("请确认(Y/N):>");
//// ret = getchar();
//// if (ret == 'Y')
//// {
//// printf("确认成功\n");
//// }
//// else
//// {
//// printf("放弃确认\n");
//// }
//// return 0;
////}
////int main()
////{
//// int ch = 0;
//// while ((ch = getchar()) != EOF)
//// {
//// if (ch < '0' || ch>'9')
//// continue;
//// putchar(ch);
//// }
//// return 0;
////}
//int main()
//{
// int i = 0;
// for (i = 1 ; i <= 10 ; i++)
// {
// if (i == 5)
// break;
// printf("%d ", i);
// }
// return 0;
//}
//int main()
//{
// int i = 0;
// for (i = 0; i <= 10; i++)
// {
// if (5 == i)
// printf("hehe\n");
// printf("haha\n");
// }
// return 0;
//}
//int main()
//{
// int arr[10] = { 1,2,3,4,5,6,7,8,9,10 };
// int i = 0;
// for (i = 0; i < 10; i++)
// {
// printf("%d", arr[i]);
// }
// return 0;
//}
//int main()
//{
// int i = 0;
// int j = 0;
// for (; i < 10; i++)
// {
// for (j=0; j < 10; j++)
// {
// printf("hehe\n");
// }
// }
// return 0;
//}
//int main()
//{
// int x, y;
// for (x = 0, y = 0; x < 2 && y < 5; x++, y++)
// {
// printf("HEHE\n");
// }
// return 0;
////}
//int main()
//{
// int i = 0;
// int k = 0;
// for (i = 0, k = 0; k == 0; i++, k++)
// {
// k++;
// printf("hehe\n");
// }
// return 0;
//}
//int main()
//{
// int i = 1;
// do
// {
// printf("%d ", i);
// i++;
// }
// while (i <= 10);
// return 0;
//}
//int main()
//{
// int sum = 0;
// int i = 0;
// int n = 0;
// int ret = 1;
// for (n = 1; n <= 3; n++)
// {
// ret = ret * n;
// sum = sum + ret;
// }
// printf("sum = %d\n",sum);
// return 0;
//
//int main()
//{
// int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
// int k = 7;
// 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)
// {
// left = mid + 1;
// }
// else if (arr[mid] > k)
// {
// right = mid - 1;
// }
// else
// {
// printf("找到了,下标是 %d\n", mid);
// break;
// }
// }
// if (left > right)
// printf("找不到,您给的数据有大问题");
// return 0;
//}
#include<string.h>
#include<windows.h>
#include<stdlib.h>
//int main()
//{
// char arr1[] = "welcome to my hometown,my baby";
// 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);
// system("cls");
// left++;
// right--;
//
// }
// printf("hello my brother,I am your besr frined");
// return 0;
//}
int main()
{
int i = 0;
char password[20] = {0};
for (i = 0; i < 3; i++)
{
printf("请输入密码:>");
scanf("%s", password);
if (0 == strcmp(password, "123456"))
{
printf("登陆成功\n");
break;
}
else
{
printf("密码错误\n");
}
}
if (i == 3)
printf("三次密码错误,请推出程序");
return 0;
}
|| 表示或者关系
&&表示并且关系
strcmp(a,b) 比较两个字符串是否相等,相等则返回为0,a大则返回大于0的数字,a小则返回小于0的数
return 直接返回起点,即int main 函数的刚开始
常量与变量比较时,通常应该把常量放在前面
% 除以之后余数为
switch(表达式),表达式必须是整型
scanf 输入
"cls"清空屏幕
!=不等于
#include<string.h> ----strlen(“aaaa”) 求字符串长度
#include<windows.h>----Sleep(1000) 休息时间为1000毫秒
#include<stdlib.h>--------system 执行系统命令