#include<stdio.h>
void chors(int n);
int main(void){
int n;
printf("How many bottles are there?\n");
scanf("%d",&n);
if(n<1){
printf("That makes no sense.\n");
return 1;
}
while(n!=0)
chors(n--);
return 0;
}
void chors(int n){
char* p1="bottles";
char* p2="bottle";
char* s1=(n==1)?p2:p1;
char* s2=(n-1>1)?p1:p2;
printf("%d %s of beer on the table, Take one,Now %d %s on the table.\n",n,s1,n-1,s2);
}
D:\Codes\test>a.exe
How many bottles are there?
3
3 bottles of beer on the table, Take one,Now 2 bottles on the table.
2 bottles of beer on the table, Take one,Now 1 bottle on the table.
1 bottle of beer on the table, Take one,Now 0 bottle on the table.
网友评论