HQ9-
Jump to navigation
Jump to search
HQ9- is a derivative of HQ9+ by User:None1.
Commands
HQ9- and HQ9+ has only 2 diffenerces:
- HQ9-'s accumulator only supports non-positive numbers.
- HQ9- has the
-
command for decrement instead of the+
command for increment in HQ9+.
Example Programs
Hello World
H
Quine
Q
99 bottles of beer
9
Decrements the accumulator
-
From an end user's perspective, it is equivalent to doing nothing.
Decreases the accumulator by 3
---
From an end user's perspective, it is equivalent to doing nothing.
Implementation
Based on the work of User:A
#include <stdio.h> int main() { unsigned long accumulator = 0; char c[1000]; for(int i=0;;i++) { scanf("%c",&c[i]); if(c[i]=='\n') break; } for(int i=0;c[i]!='\0';i++) { if(c[i]=='H') printf("Hello, World!\n"); else if(c[i]=='Q') printf("%.*s", (int)sizeof c, c); else if(c[i]=='9') { for(int j=99;j>0;j--) { printf("%d bottles of beer on the wall,\n%d bottles of beer.\n", j, j); printf("Take one down, pass it around,\n%d bottles of beer on the wall.\n", j-1); } printf("1 bottle of beer on the wall,\n1 bottle of beer.\nTake one down, pass it around,\nno more bottles of beer on the wall.\n"); } else if(c[i]=='-') accumulator--; } return 0; }