阳阳买苹果

阳阳买苹果,每个苹果0.8元,阳阳第一天买两个苹果,第二天开始每天买前一天的两倍,直到购买的苹果个数为不超过100的最大值,求阳阳每天平均花多少钱

#include <stdio.h>

int main(void)
{

        float apple_price = 0.8;
        float pay = 0;

        int day = 0;
        int count = 0;
        int buy = 0;


        while(1)
        {
                ++day;
                if(day == 1){
                        buy = 2;
                } else {
                        buy = count*2;
                }
                if(count + buy > 100){ 
                        --day;
                        break;
                }
                pay += buy*apple_price;
                count += buy;
        }


        printf("%f",pay/day);

        return 0;
}