#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h> #include<string.h> // //int main() //{ //?? ?int ch = 0; //?? ?while (ch = getchar() != EOF) //?? ?{ //?? ??? ?putchar(ch); //?? ?} //?? ?//char p[20] = { 0 }; //?? ?//printf("请输入密码:"); //?? ?//scanf("%s", p); //?? ?int ch = 0; //?? ?while ((ch = getchar()) != EOF) //?? ?{ //?? ??? ?if (ch < '0' || ch>'9') //?? ??? ??? ?continue; //?? ??? ?putchar(ch); //?? ?} //?? ?return 0; //} //int main() //{ //?? ?int n=0 ; //?? ?int sum = 1; //?? ?int a = 0; //?? ?scanf("%d", &n); //?? ?for (int i = 1; i <= n; i++) //?? ?{ //?? ??? ?sum = sum*i; //?? ??? ?a = a + sum; //?? ?} //?? ?printf("%d\n", sum); //?? ?printf("%d", a); //?? ?return 0; //} //找到有序数组中的k值的下标 //int main() //{ //?? ?char arr[10] = { 1,2,3,4,5,6,7,8,9 }; //?? ?int k = 17; //?? ?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("找到了 k的下标为:%d",mid); //?? ??? ??? ?break; //?? ??? ?} //?? ??? ?if (left < right) //?? ??? ?{ //?? ??? ??? ?printf("找不到"); //?? ??? ?} //?? ?} // //?? ?return 0; //} //演示多个字符从两端,向中间汇集 //int main() //{ //?? ?char arr1[] = "welcome to china!!!!!"; //?? ?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); //?? ??? ?left++; //?? ??? ?right--; //?? ? //?? ?} //?? ? //?? ?return 0; // // //} //模拟登录界面 int main() { ?? ?int i = 0; ?? ?char password[20] = {0};
?? ?for (i = 0; i < 3; i++) ?? ?{ ?? ??? ?printf("请输入密码:"); ?? ??? ?scanf("%s", &password); ?? ??? ?if (strcmp(password, "123456") == 0) ?? ??? ?{ ?? ??? ??? ?printf("密码正确\n"); ?? ??? ??? ?break; ?? ??? ?} ?? ??? ?else ?? ??? ?{ ?? ??? ??? ?printf("密码错误\n"); ?? ??? ??? ? ?? ??? ?} ?? ?} ?? ?if (i == 3) ?? ??? ?printf("三次密码均错误\n"); ?? ?return 0; }
|