东华大学 oj23——整数的尾除

问题描述 :

一个整数,只知道前几位为a,不知道末二位,被另一个整数b除尽了,那么该数的末二位该是什么呢?

输入说明 :

第一行为T,以下T行,每行为一组测试数据,包含两个整数a,b(0<a<10000, 10<b<100)。

输出说明 :

对应每组数据,将满足条件的所有尾数在一行内输出,格式见范例。同组数据的输出,其每个尾数之间空一格,行首与行尾没有空格。

输入范例 :
2
555 153
1233 52

输出范例 :
39
44 96

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
    
    
	int a,b,T,valuea,i,j,k,count=0;
	int temp[30];
	scanf("%d",&T);
	while(count!=T){
    
    
		scanf("%d %d",&a,&b);
		++count;
		k=0;
		for(i=0;i<30;i++){
    
    
			temp[i]=0;
		}
		for(i=0;i<=9;i++){
    
    
			for(j=0;j<=9;j++){
    
    
				valuea=a*100;
				valuea+=(j+10*i);
				if(valuea%b==0){
    
    
					temp[k]=(j+10*i);
					++k;
				}
			}	
		}
		
		for(i=0;i<k;i++){
    
    
			if(i!=k-1){
    
    
				printf("%d ",temp[i]);
			}else{
    
    
				printf("%d",temp[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_44169095/article/details/113695098