3 条题解

  • 1
    @ 2025-4-25 19:01:21
    
    
    
    第一步:
    for(int i=0;i<13;i++)
    	{
    		cin>>c;
    		if(c>='0'&&c<='9')
    			a[j++]=c-'0';
    		if(c=='X')
    			a[j++]=10;
    	}   
    
    第二步
      for(int i=0;i<9;i++)  //计算和的方式
    	{
    		s+=a[i]*(i+1);
    	}
    
      第三步:
      if(s%11==a[9]||s%11==10&&a[9]==10) cout<<"Right";  //校验最后一位
    	else
    	{	
    		if(s%11<10)
    		 printf("%d-%d%d%d-%d%d%d%d%d-%d",a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],s%11);
    	    else
    		  printf("%d-%d%d%d-%d%d%d%d%d-%c",a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],'X');
    	}
    
    
    • 0
      @ 2025-4-25 19:44:07

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

      int main() { char a[14];

      for(int i=0;i<13;i++)
      	cin>>a[i];
      	
      int x=0,c=0;
      for(int i=0;i<12;i++)
      	if(a[i]>='0'&&a[i]<='9')
       	{   
      		c++;
        			x+=(a[i]-'0')*c;
      	}
      		 
      int y;
      if(x%11==(a[12]-'0'))	
      	y=1;
      else if(x%11!=10)
      {
      	y=0;
      }
      else if(x%11==10)
      {
      	if(a[12]=='X')
      		y=1;
      	else
      		y=0;
      }
      
      if(y==1)
      	cout<<"Right";
      else
      {
      	for(int i=0;i<12;i++)
      		cout<<a[i];
      	
      		if(x%11!=10)	
      			cout<<x%11;
      		else if(x%11==10)
      			cout<<"X";
      }	
      	
      return 0;
      

      }

      • 0
        @ 2025-4-25 19:25:53
        if(x%11==(a[12]-'0'))cout<<"Right";
        	else if(x%11==10 && a[12]=='X')cout<<"Right";
        	else if(x%11!=(a[13]-'0') && x%11==10)
        	{
        		for(int i=0;i<12;i++) cout<<a[i];
        		cout<<"X";
        	}
        	else 
        	{
        	for(int i=0;i<12;i++) 
        	cout<<a[i];
        	cout<<x%11;
            }
        
        • 1

        信息

        ID
        160
        时间
        1000ms
        内存
        16MiB
        难度
        8
        标签
        递交数
        110
        已通过
        19
        上传者