為什麼我的代碼調用一個函數兩次？

Cenk28
``````    #include <stdio.h>
int bolucu(int n){
int temp;
temp=n;
int basamak=0;
while(temp != 0){
temp/=10;
++basamak;
}
int digits = 0;
int m = n;
while (m) {
digits++;
m /= 10;
}
digits /= 2;
int tmp = 0, lower_half = 0;
while (digits--) {
tmp *= 10;
tmp += n % 10;
n /= 10;
}
while (tmp) {
lower_half *= 10;
lower_half += tmp % 10;
tmp /= 10;
}
if (basamak % 2==1){
n/=10;
}
int a;
int b;
a = n;
b=lower_half;
printf("%d %d\n",a,b);
int loopTemp;
for(int i=0;i<10;i++){
a=3*a+2;
b=2*b+3;
if(a>b){
temp=a;
a=b;
b=temp;
}
if(a==b){
printf("Congratulations you caught one!!!\n");
return 1;
break;
}
}
if(a!=b){
printf("10 tries were not enough!\n");
return 2;
}
}
int main()
{
int number;
printf("\nEnter a number with at least two digits: ");
scanf("%d",&number);
bolucu(number);
while(bolucu(number) != 1){
printf("\nEnter a new number: ");
scanf("%d",&number);
printf("%d",bolucu(number));
}
return 0;
}
``````

``````int main()
{
int number;
printf("\nEnter a number with at least two digits: ");
scanf("%d", &number);
int result = bolucu(number);
while (result != 1)
{
printf("\nEnter a new number: ");
scanf("%d", &number);
result = bolucu(number);
printf("%d", result);
}
return 0;
}
``````

0 条评论