返回列表 發帖

a224. 明明愛明明

本帖最後由 李知易 於 2025-2-8 12:08 編輯

附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. #include<bits/stdc++.h>
  2. using namespace std;

  3. int main()
  4. {
  5.     string a;
  6.     while(cin>>a)
  7.     {
  8.         int c=0;
  9.         int b[26]={0};
  10.         for(int i=0;i<a.length();i++)
  11.         {
  12.             if(a[i]>=65 and a[i]<=90)
  13.             {
  14.                 b[a[i]-65]++;
  15.             }
  16.             else if(a[i]>=97 and a[i]<=122)
  17.             {
  18.                 b[a[i]-97]++;
  19.             }
  20.         }
  21.         for(int i=0;i<26;i++)
  22.         {
  23.                 if(b[i]%2==1)
  24.                     c++;
  25.         }
  26.         if(a.length()%2==1)
  27.         {
  28.             if(c>1)
  29.                 cout<<"no..."<<endl;
  30.             else
  31.                 cout<<"yes !"<<endl;
  32.         }
  33.         else
  34.         {
  35.             if(c>0)
  36.                 cout<<"no..."<<endl;
  37.             else
  38.                 cout<<"yes !"<<endl;
  39.         }
  40.     }

  41.     return 0;
  42. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;

  3. int main()
  4. {
  5.     string s;


  6.     while(cin>>s){
  7.         int a[26]={0};
  8.         string str;
  9.         for(int i=0;i<s.length();i++){
  10.            char c=s[i];
  11.            if(c>='A'&&c<='Z'){
  12.                 a[c-65]++;
  13.            }else if(c>='a'&&c<='z'){
  14.                 a[c-97]++;
  15.            }
  16.         }
  17.         int b=-1;
  18.         for(int i=0;i<26;i++){
  19.             if(a[i]%2!=0){
  20.                 b++;
  21.             }
  22.         }
  23.         if(b>0){
  24.             cout<<"no..."<<endl;
  25.         }else{
  26.             cout<<"yes !"<<endl;
  27.         }
  28.     }
  29.     return 0;
  30. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string s;
  4. int main()
  5. {
  6.     while(cin>>s)
  7.     {
  8.         bool b=1;
  9.         int n[26]={0},len=0;
  10.         for(int i=0;i<s.length();i++)
  11.         {
  12.             if(s[i]>='a')
  13.             {
  14.                 s[i]-=97;
  15.                 n[s[i]]++;
  16.                 len++;
  17.             }
  18.             else if(s[i]>='A' and s[i]<='Z')
  19.             {
  20.                 s[i]-=65;
  21.                 n[s[i]]++;
  22.                 len++;
  23.             }
  24.         }
  25.         for(int i=0;i<26;i++)
  26.         {
  27.             if(len%2!=0)
  28.             {
  29.                 if(n[i]%2!=0)
  30.                     {
  31.                         n[i]++;
  32.                         break;
  33.                     }
  34.             }
  35.             else
  36.                 break;
  37.         }
  38.         for(int i=0;i<26;i++)
  39.         {
  40.             if(n[i]%2==0)
  41.             {
  42.                 continue;
  43.             }
  44.             else
  45.             {
  46.                 cout<<"no..."<<endl;
  47.                 b=0;
  48.                 break;
  49.             }
  50.         }
  51.         if(b==0)
  52.         {
  53.             continue;
  54.         }
  55.         else
  56.             cout<<"yes !"<<endl;
  57.     }
  58. }
複製代碼
    ⪔〠   

TOP

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. string str;
  4. int main()
  5. {
  6.     while(cin>>str)
  7.     {
  8.         int sum[26]= {0};
  9.         for(int i=0; i<str.length(); i++)
  10.         {
  11.             char c=str[i];
  12.             if(c>='A' && c<='Z')
  13.             {
  14.                 c+=32;
  15.                 str[i]=c;
  16.             }
  17.         }
  18.         for(int i=0; i<str.length(); i++)
  19.         {
  20.             char c=str[i];
  21.             if(c>='a' && c<='z')
  22.             {
  23.                 sum[c-'a']++;
  24.             }
  25.         }
  26.         int cnt=0;
  27.         for(int i=0; i<26; i++)
  28.         {
  29.             if(sum[i]%2!=0)
  30.                 cnt++;
  31.         }
  32.         if(cnt>1)
  33.             cout<<"no..."<<endl;
  34.         else
  35.             cout<<"yes !"<<endl;
  36.     }
  37.     return 0;
  38. }
複製代碼

TOP

返回列表