X bottles of beers, take y down, x and y are in Real Numbers Set

From Esolang
Jump to navigation Jump to search

x bottles of beers, take y down, x and y are in Real Numbers Set is a program designed and implemented by PSTF.

This is the ADVANCED version of 99 bottles of beer. It receives two real number as input and assign them to x and y, and then print these lyrics(x and y has precision of 3 decimal digit, end if x≤0):

x bottles of beer on the wall,
x bottles of beer.
Take y down and pass it around, 
x-y bottles of beer on the wall.

x-y bottles of beer on the wall,
x-y bottles of beer.
Take y down and pass it around, 
x-(2×y) bottles of beer on the wall.

--snip--

Implementations

Python

x = float(input())
y = float(input())
while x > 0:
    print(f"{x} bottles of beers on the wall, \n{x} bottles of beers. \nTake {y} down and pass it around, \n")
    x -= y
    print(f"{x} bottles of beers on the wall. \n\n")
print(f"""
No more bottles of beer on the wall, 
no more bottles of beer.
Go to the store and buy some more, 
{x} bottles of beer on the wall.
""")

C++

#include<bits/advc++.h>
using namespace std;
string unit = "bottles";
long double x, y;
int main()
{
	printf("Please input: ");
	cin >> x;
	printf("Please input again: ");
	cin >> y;
	system("cls");
	for (long double i = x; i > 0; i -= y)
	{
		if(i==1.0)
		{
			unit="bottle";
		}
		else
		{
			unit="bottles";
		}
		cout << fixed << setprecision(3) << i << " " << unit << " of beer on the wall, \n";
		cout << fixed << setprecision(3) << i << " " << unit << " of beer. \n";
		cout << "Take " << y << " down, pass it around, \n";
		cout << fixed << setprecision(3) << i - y << " " << unit << " of beer on the wall.\n\n";
		Sleep(50);
	}
	cout << "No more bottles of the beers on the wall, \n";
	cout << "No more bottles of the beers. \n";
	cout << "Go to the store and buy some more, \n";
	cout << fixed << setprecision(3) << x << " bottles of the beers on the wall.";
	return 0;
}

!中文

以“请输入初始数值:”作为提示输入 x 。
以“请输入\“增量\”:”作为提示输入 y 。
将 i 初始化为 x 。
清空屏幕。
重复执行以下代码直至 i 不大于 0 :
{
    输出“%1 bottles of beers on the wall, \n%1 bottles of beers.\n”。%1将被 i 替代。
    将 i 减去 y 。
    输出“Take %1 down and pass it around,\n %2 bottles of beers on the wall.\n\n”。%1将被 y 替代,%2将被 i 替代。
}
输出“No more bottles of beers on the wall, \nNo more bottles of beers. \n”。
输出“Go to the store and buy some more, \n%1 bottles of beers on the wall.”。%1将被 x 替代。

See also

99 bottles of beer

Categories