Hoshimati @ 2024-11-18 22:12:35
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
int judge(char* a) {
int len = strlen(a);
if (len < 6 || len > 12) {
return 0;
}
int num = 0, low = 0, nal = 0, up = 0;
for (int i = 0; i < len; i++) {
if (a[i] >= 'a' && a[i] <= 'z') {
low = 1;
}
else if (a[i] >= '0' && a[i] <= '9') {
num = 1;
}
else if (a[i] >= 'A' && a[i] <= 'Z') {
up = 1;
}
else if (a[i] == '!' || a[i] == '@' || a[i] == '#' || a[i] == '$') {
nal = 1;
}
else {
return 0;
}
}
if ((low + num + up < 2) || nal != 1) {
return 0;
}
return 1;
}
int main() {
char arr[102];
scanf("%s", &arr);
char* arr1[100];
char* p = strtok(arr, ",");
int i = -1;
int j = 0;
while (p != NULL) {
arr1[++i] = (char*)malloc(strlen(p) + 1);
strcpy(arr1[i], p);
p = strtok(NULL, ",");
if (judge(arr1[i])) {
j++;
}
}
for (int k = 0; k < j; k++) {
if (judge(arr1[k])) {
printf("%s", arr1[k]);
}
if (k != j - 1) {
printf("\n");
}
}
for (int k = 0; k < i; k++) {
free(arr1[k]);
}
return 0;
}
by PengRuiXuan @ 2024-11-20 20:13:16
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n; // 读取进制的数量
while (n--) {
string s;
cin >> s; // 读取每个字符串
int len = s.length(), mx = 0;
for (int i = 0; i < len; i++) {
mx = max(mx, int(s[i])); // 找到字符串中的最大值
}
if (mx > 'F') cout << "0 0 0 0" << endl; // 不可能是十六进制
else if (mx >= 'A') cout << "0 0 0 1" << endl; // 可能是十六进制
else if (mx >= '8') cout << "0 0 1 1" << endl; // 可能是八进制
else if (mx >= '2') cout << "0 1 1 1" << endl; // 可能是二进制
else cout << "1 1 1 1" << endl; // 四种进制皆有可能
}
return 0;
}
@Hoshimati
by PengRuiXuan @ 2024-11-20 20:13:43
@Hoshimati
求互关
by PengRuiXuan @ 2024-11-21 19:16:56
#include<bits/stdc++.h>
using namespace std;
int n;
string t[100];
int main ()
{
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{
if(s[i]!=',')
{
t[n]+=s[i];
}
else
{
n++;
}
}
for(int i=0;i<=n;i++)
{
string m=t[i];
int l=m.size();
int a=0,b=0,c=0,d=0,e=0;
if(l<6||l>12)
{
continue;
}
for(int j=0;j<l;j++)
{
if(islower(m[j]))
{
a++;
}
else if(isupper(m[j]))
{
b++;
}
else if(isdigit(m[j]))
{
c++;
}
else if(m[j]=='!'||m[j]=='@'||m[j]=='$'||m[j]=='#')
{
d++;
}
else
{
e++;
}
}
if(e!=0||d==0||a==0&&b==0||a==0&&c==0||b==0&&c==0)
{
continue;
}
else
{
cout<<m<<endl;
}
}
return 0;
}
@Hoshimati
by PengRuiXuan @ 2024-11-21 19:17:20
@Hoshimati
发错代码了,不好意思。
by Hoshimati @ 2024-11-24 20:24:05
@PengRuiXuan 虽然我不会cpp但还是谢谢佬OAO
by caoyichen1 @ 2024-12-01 16:49:28
#include<bits/stdc++.h>
using namespace std;
bool judge_whether_the_password_is_compliant(string m,int t)
{
if (t<6||t>12)
{
return 0;
}
bool does_the_capital_letter_match=0,do_lowercase_letters_match=0,does_the_figure_match=0,does_the_special_character_match=0;
for (int i=0;m[i]!='\0';i++)
{
if (m[i]>='A'&&m[i]<='Z')
{
does_the_capital_letter_match=1;
}
else if(m[i]>='a'&&m[i]<='z')
{
do_lowercase_letters_match=1;
}
else if(m[i]>='0'&&m[i]<='9')
{
does_the_figure_match=1;
}
else if(m[i]=='!'||m[i]=='@'||m[i]=='#'||m[i]=='$')
{
does_the_special_character_match=1;
}
else
{
return 0;
}
}
if (!does_the_special_character_match||does_the_capital_letter_match+do_lowercase_letters_match+does_the_figure_match<2)
{
return 0;
}
return 1;
}
int main()
{
char n[102],m[102];
int t=0;
cin>>n;
for (int i=0;n[i]!='\0';i++)
{
if (n[i]!=',')
{
m[t]=n[i];
t++;
}
else
{
m[t]='\0';
if (judge_whether_the_password_is_compliant(m,t))
{
cout<<m<<endl;
}
t=0;
}
}
if (t>0)
{
m[t]='\0';
if (judge_whether_the_password_is_compliant(m,t))
{
cout<<m;
}
}
return 0;
}
by An15163220501 @ 2025-01-01 13:58:02
@Hoshimati
蒟蒻代码
# include <bits/stdc++.h>
using namespace std;
int cnt = 1;
string s[105];
int main()
{
string a,t;
cin >> t;
for (int i = 0;i < t.length();i++)
{
if (t[i] != ',')
s[cnt] += t[i];
else
cnt++;
}
for (int i = 1;i <= cnt;i++)
{
string ss = s[i];
bool a = false,b = false,c = false,d = false,e = false;
if (ss.length() < 6 || 12 < ss.length())
continue;
for (int j = 0;j < ss.length();j++)
{
if ('a' <= ss[j] && ss[j] <= 'z')
a = true;
else if ('A' <= ss[j] && ss[j] <= 'Z')
b = true;
else if ('0' <= ss[j] && ss[j] <= '9')
c = true;
else if (ss[j] == '!' || ss[j] == '@' || ss[j] == '#' || ss[j] == '$')
d = true;
else
{
e = true;
break;
}
}
if (e)
continue;
if ((a && b || a && c || b && c) && d)
cout << ss << endl;
}
return 0;
}
无耻地求关