1 solutions

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

    C :

    #include<stdio.h>
    #include<stdlib.h>
    
    int main()
    {
    	int j;
    	int n;
    	scanf("%d", &n);
    	int *a = (int *)malloc(n*sizeof(int));
    	int *b = (int *)malloc(n*sizeof(int));
    	int *ans = (int *)malloc(n*sizeof(int));
    	for(j = 0; j < n; j++)
    	{
    		scanf("%d%d", &a[j], &b[j]);
    		ans[j] = 0;
    	}
    	for(j = 0; j < n; j++)
    	{
    		int c = 0;
    		for(int i = 9; i >= 0; i--)
    		{
    			c = (a[j]%10 + b[j]%10 + c) > 9 ? 1 : 0;
    			ans[j] += c;
    			a[j] /= 10;
    			b[j] /= 10;
    		}
    	}
    	for(j = 0; j < n; j++)
    	{
    		printf("%d\n", ans[j]);
    	}
    	free(a);
    	free(b);
    	free(ans);
    	return 0;
    } 
    
    • 1

    【设计型】第11章:指针和数组 11.8 进位次数

    Information

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