Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
296
144
#include <bits/stdc++.h>
using namespace std;
string s,a;
int n,d[10001];
void solve(string s)
{
for (int i=1;i<=10001;i++) d[i]=0;
int res1=0,res2=0,res3=0;
for (int i=0;i<s.length();i++)
{
d[int(s[i])]++;
}
for (int i=48;i<=57;i++)
{
if (d[i]>0) res1++;
}
for (int i=65;i<=90;i++)
{
if (d[i]>0) res2++;
}
for (int i=97;i<=122;i++)
{
if (d[i]>0) res3++;
}
if (res1>0&&res2==0&&res3==0) cout<<s<<endl;
else if (res1==0&&res2>0&&res3==0) cout<<s<<endl;
else if (res1==0&&res2==0&&res3>0) cout<<s<<endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("dungmk.inp","r",stdin);
freopen("dungmk.out","w",stdout);
cin>>n;
getline(cin,a);
for (int i=1;i<=n;i++)
{
getline(cin,s);
solve(s);
}
}
//ProDev
Hãy giúp mọi người biết câu trả lời này thế nào?
#include <bits/stdc++.h>
using namespace std;
bool hoa(string s) {
for (int i=0; i<s.length(); i++) if (s[i]<65 || s[i]>90) return false;
return true;
}
bool thuong(string s) {
for (int i=0; i<s.length(); i++) if (s[i]<97 || s[i]>122) return false;
return true;
}
bool so(string s) {
for (int i=0; i<s.length(); i++) if (s[i]<48 || s[i]>57) return false;
return true;
}
int main() {
int n;
cin >> n;
string arr[n];
for (int i=0; i<n; i++) cin >> arr[i];
for (int i=0; i<n; i++) {
if (hoa(arr[i])) {
cout << arr[i] << endl;
continue;
}
if (thuong(arr[i])) {
cout << arr[i] << endl;
continue;
}
if (so(arr[i])) cout << arr[i] << endl;
}
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin