1 条题解

  • 0
    @ 2025-9-9 23:46:02

    C :

    #include<stdio.h>
    #include<stdlib.h>
    
    int main()
    { 
      int ans[128];
      int i,n,flag;
      char str[10];
      while(gets(str)){
        n=strlen(str);
        for(i=0;i<128;i++)
          ans[i]=0;
        for(i=0;i<n;i++)
          ans[str[i]]++;
        for(flag=i=0;i<128;i++)
          if(ans[i]%2)flag++;
        if(flag<2)printf("Yes\n");
          else printf("No\n");
      }
      return 0;
    }
    

    C++ :

    #include<iostream>
    #include<cmath>  
    #include<queue>
    #include<stack>
    #include<vector>  
    #include<algorithm>  
    #include<cstdio>  
    #include<cstring>  
    using namespace std;  
    #define N 10010
    
    
    int main()
    {
    	int i, j;
    	char s[100];
    	while(cin >> s){
    		int cnt[300] = {0};
    		for(i=0; s[i] != 0; i++){
    			cnt[s[i]]++;
    		}
    		int len = strlen(s);
    		int jishu = 0;
    		for(i=0; i<300; i++){
    			if(cnt[i] % 2) jishu++;
    		}
    		if(len % 2 == 0 && jishu == 0){
    			cout << "Yes\n";
    		}
    		else if(len % 2 == 1 && jishu == 1){
    			cout << "Yes\n";
    		}
    		else{
    			cout << "No\n";
    		}
    	}
    	return 0;
    }
    

    Pascal :

    var s:string;
    procedure pd;
    var i,k,n:longint;
        a,b:array[0..1000] of longint;
    begin
      fillchar(a,sizeof(a),0);
      fillchar(b,sizeof(b),0);
      k:=0;
      for i:=1 to length(s) do
       begin
        if b[ord(s[i])]=0 then
         begin
          inc(k);
          a[k]:=ord(s[i]);
         end;
         inc(b[ord(s[i])]);
       end;
      n:=0;
      for i:=1 to k do if b[a[i]] mod 2=1 then inc(n);
      if n<=1 then writeln('Yes') else writeln('No');
    end;
    begin
      while not eof do
       begin
         readln(s);
         if length(s)=0 then exit;
         if length(s)=1 then writeln('Yes') else pd;
       end;
    end.
    

    Java :

    import java.util.Scanner;
    
    
    public class Main {
    		public	static void main (String[] args ) {
    			Scanner in=new Scanner(System.in);
    			while (in.hasNext()) {
    				String s=in.next();char [] a=new char[s.length()];int []b=new int[s.length()];
    				for(int i=0;i<s.length();i++) {
    					a[i]=s.charAt(i);
    				}
    				for(int j=0;j<s.length();j++) {int con=0;
    					for(int x=0;x<s.length();x++) {
    						if(s.charAt(j)==a[x]) {
    							con++;
    						}
    					}
    					b[j]=con;
    				}int sum=0;
    				for(int y=0;y<s.length();y++) {
    					if(b[y]==1) {
    						sum++;
    					}
    				}
    				if(sum>=2) {
    					System.out.println("No");
    				}
    				else
    					System.out.println("Yes");
    				
    			}
    		}
    }
    
    
    • 1

    信息

    ID
    983
    时间
    1000ms
    内存
    32MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者