Mirror-machine

From Esolang
Jump to navigation Jump to search

A Mirror-machine is an extremely simple program type invented by User:ReplayShells to check decision, addition, subtraction, loops, input and outputs. Process:

  • Input vars a,b (b is unsigned.)
  • Increment a
  • Decrement b
  • If a is not 0:
    • Print a
    • Set a to 0
  • If b is not 1:
    • Print b
  • While b is not 0
    • Print b
    • Decrement b
  • Input a,b
  • Print a - b
  • Print ABC
  • Terminate program

Implementations

C

#include <stdio.h>
int main(void)
{
	int a;
	unsigned b;
	scanf("%d %u", &a, &b);
	++a;
	--b;
	if(a != 0)
	{
		printf("%d\n", a);
		a = 0;
	}
	if(b != 1)
		printf("%u\n", b);
	while(b != 0)
	{
		printf("%u\n", b);
		--b;
	}
	scanf("%d %u", &a, &b);
	printf("%d\n", a - b);
	printf("ABC\n");
	return 0;
}