1 solutions

  • 0
    @ 2024-12-10 21:47:36

    C :

    #include<stdio.h>
    #include<math.h>
    int main()
    {
    	int n;
    	scanf("%d", &n);
    	int k = 1, s = 0;
    	for(;;)
    	{
    		s += k;
    		if(s >= n)
    		{
    			printf("%d/%d\n", s-n+1, k-s+n);
    			break;
    		}
    		k++;
        }
    	return 0;
    } 
    

    C++ :

    #include<stdio.h>
    #include<math.h>
    int main()
    {
    	int n;
    	scanf("%d", &n);
    	int k = 1, s = 0;
    	for(;;)
    	{
    		s += k;
    		if(s >= n)
    		{
    			printf("%d/%d\n", s-n+1, k-s+n);
    			break;
    		}
    		k++;
        }
    	return 0;
    } 
    
    • 1

    【设计型】第11章:指针和数组 Cantor的数表

    Information

    ID
    485
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By