2 solutions

  • 0
    @ 2023-2-9 22:33:44
    求佬指点怎么改进
    #include<stdio.h>
    int sum[36]={0};
    void fun(int n,int m);
    int main()
    {
    	int n,m;
    	scanf("%d%d",&n,&m);
    	fun(n,m);
    	
    	return 0;
    }
    
    
    
    void fun(int n,int m)
    {
    	char s[37]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    	int t=1;
    	while(n>m)
    	{
    		sum[t]=n%m;
    //		printf("%d\n",n%m);
    		t++;
    		n=n/m;
    	//
    		if(m>n)
    		{
    			sum[t]=n;
    		}
    	
    	}
    //	printf("%d\n",t);
    	while(t>0)
    	{
    	//	printf("%d\n",sum[t]);
    		printf("%c",s[sum[t]]);
    	t--;
    	 } 
    }
    

    Information

    ID
    6691
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    4
    Tags
    (None)
    # Submissions
    27
    Accepted
    16
    Uploaded By