如何才能不用減號實現兩個整數相減呢?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
    long long int x = log10(0.1);
    //printf("%d",x);
    long long int a,b;
    while(scanf("%lld%lld",&a,&b) != EOF)
    {
        printf("%lld\n",a+x*b);
    }
    return 0;
}


因爲這個題目限制了減號的使用,所有就考慮創造-1,這樣就充當了減號的作用。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章