2 条题解

  • 6
    @ 2021-11-16 17:40:01
    #include <stdio.h>
    #include <iostream>
    #include <math.h>
    #include <string.h>
    using namespace std;
    bool f(char l , char r);
    void out(int p , char s);
    void calc(int p2, int p1,char j);
    int main()
    {
    	int p1,p2,p3;
    	cin >>p1 >> p2 >> p3;
    	string a;
    	cin >> a;
    	int len = a.size();
    	for(int i = 0 ; i < len ; i++)
    	{
    		if(a[i+1] == '-')
    		{
    			cout<< a[i];
    			char l , r;
    			l = a[i] , r = a[i+2];
    			if(f(l , r))
    			{
    				l++;
    				r--;
    				if(p3 == 1)
    					for(int j = l ; j <= r ; j++)
    						calc(p2,p1,j); 
    				else 
    					for(int j = r ; j >= l ; j--)
    						calc(p2,p1,j);
    			}
    			else 
    				cout << "-";
    			i++;
    		}
    		else 
    			cout << a[i];
    	} 
    }
    
    bool f(char l , char r)
    {
    	if(!(l >='0' && l <= 57 || l >= 'A' && l <= 'Z' || l >= 'a' && l <= 'z' )) return false;
    	if(!(r >='0' && r <= 57 || r >= 'A' && r <= 'Z' || r >= 'a' && r <= 'z' )) return false;
    	if(l >= r) return false;
    	if(l <= '9' && r >'9' ) return false;
    	if(l <= 'Z' && r >= 'a') return false;
    	return true;
    }
    void out(int p , char s)
    {
    	if(p == 3)
    	{
    		cout << "*";
    		return; 
    	}
    	if(s <= 57)
    	{
    		cout << s;
    		return ;
    	}
    	if(s <= 90)
    		s+= 32;
    	if(p == 1)
    		cout << s;
    	else
    		cout << (char)(s-32);
    }
    void calc(int p2, int p1,char j)
    {
    	for(int k = 0 ; k < p2 ; k++)
    		out(p1,j);
    }
    
    
    • 4
      @ 2021-10-23 20:27:07
      /*****************************************
      备注:
      ******************************************/
      #include <queue>
      #include <math.h>
      #include <stack>
      #include <stdio.h>
      #include <iostream>
      #include <vector>
      #include <iomanip>
      #include <string.h>
      #include <algorithm>
      using namespace std;
      #define LL long long
      const int N = 1e5 + 10;
      const int INF = 0x3f3f3f3f;
      char s[N];
      int main()
      {
      	int p1,p2,p3;
      	cin >> p1 >> p2 >> p3;
      	cin >> s;
      	int len = strlen(s);
      	for(int i = 0 ; i < len ; i++)
      	{
      		if(s[i+1] != '-') 
      			cout << s[i];
      		else if((s[i] >= 48 && s[i] <= 57) || 
      			(s[i] >='A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z'))
      		{
      			char l = s[i] , r = s[i+2];
      			cout << s[i] ; 
      			if(l >= r || i+2 >= len || (( l <= 57 && r > 57) 
      				||(l <= 90 && r > 90)))
      				continue;
      			else if( r == l + 1)
      			{
      				i = i+1;
      				continue;
      			}
      			if(p3 == 1)
      			{
      				if(l >= 97 )
      					l -= 32 , r -= 32;
      				for(int j = l+1; j < r ; j++)
      				{
      					char t = j;
      					if(p1 == 1 && s[i] >= 65)
      						t += 32;
      					else if( p1 == 3)
      						t = '*';
      					for(int k = 0 ; k < p2 ; k++)
      						cout << t;
      				}
      				i = i + 1;
      			}
      			else 
      			{
      				if(l >= 97 )
      					l -= 32 , r -= 32;
      				for(int j = r-1 ; j > l ; j--)
      				{
      					char t = j;
      					if(p1 == 1 && s[i] >= 65)
      						t += 32;
      					else if( p1 == 3)
      						t = '*';
      					for(int k = 0 ; k < p2 ; k++)
      						cout << t;
      				}
      				i = i + 1;
      			}
      		}
      		else 
      			cout <<s[i];
      	}
      	return 0;
      }
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      • 1

      信息

      ID
      696
      时间
      1000ms
      内存
      128MiB
      难度
      6
      标签
      递交数
      72
      已通过
      24
      上传者