標題:
a224. 明明愛明明
[打印本頁]
作者:
李知易
時間:
2025-2-8 10:06
標題:
a224. 明明愛明明
本帖最後由 李知易 於 2025-2-8 12:08 編輯
[attach]20652[/attach]
作者:
洪承廷
時間:
2025-2-8 10:41
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a;
while(cin>>a)
{
int c=0;
int b[26]={0};
for(int i=0;i<a.length();i++)
{
if(a[i]>=65 and a[i]<=90)
{
b[a[i]-65]++;
}
else if(a[i]>=97 and a[i]<=122)
{
b[a[i]-97]++;
}
}
for(int i=0;i<26;i++)
{
if(b[i]%2==1)
c++;
}
if(a.length()%2==1)
{
if(c>1)
cout<<"no..."<<endl;
else
cout<<"yes !"<<endl;
}
else
{
if(c>0)
cout<<"no..."<<endl;
else
cout<<"yes !"<<endl;
}
}
return 0;
}
複製代碼
作者:
高鋐鈞
時間:
2025-2-8 11:07
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
while(cin>>s){
int a[26]={0};
string str;
for(int i=0;i<s.length();i++){
char c=s[i];
if(c>='A'&&c<='Z'){
a[c-65]++;
}else if(c>='a'&&c<='z'){
a[c-97]++;
}
}
int b=-1;
for(int i=0;i<26;i++){
if(a[i]%2!=0){
b++;
}
}
if(b>0){
cout<<"no..."<<endl;
}else{
cout<<"yes !"<<endl;
}
}
return 0;
}
複製代碼
作者:
徐啟祐
時間:
2025-2-8 11:07
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
while(cin>>s)
{
bool b=1;
int n[26]={0},len=0;
for(int i=0;i<s.length();i++)
{
if(s[i]>='a')
{
s[i]-=97;
n[s[i]]++;
len++;
}
else if(s[i]>='A' and s[i]<='Z')
{
s[i]-=65;
n[s[i]]++;
len++;
}
}
for(int i=0;i<26;i++)
{
if(len%2!=0)
{
if(n[i]%2!=0)
{
n[i]++;
break;
}
}
else
break;
}
for(int i=0;i<26;i++)
{
if(n[i]%2==0)
{
continue;
}
else
{
cout<<"no..."<<endl;
b=0;
break;
}
}
if(b==0)
{
continue;
}
else
cout<<"yes !"<<endl;
}
}
複製代碼
作者:
楊惇翔
時間:
2025-2-8 12:04
#include <bits/stdc++.h>
using namespace std;
string str;
int main()
{
while(cin>>str)
{
int sum[26]= {0};
for(int i=0; i<str.length(); i++)
{
char c=str[i];
if(c>='A' && c<='Z')
{
c+=32;
str[i]=c;
}
}
for(int i=0; i<str.length(); i++)
{
char c=str[i];
if(c>='a' && c<='z')
{
sum[c-'a']++;
}
}
int cnt=0;
for(int i=0; i<26; i++)
{
if(sum[i]%2!=0)
cnt++;
}
if(cnt>1)
cout<<"no..."<<endl;
else
cout<<"yes !"<<endl;
}
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2