Post History
In this simple challenge, create a short program that takes 2 ints as input, output them, swap their places, then output them again. Those 2 integers can't be the same number. The program with the ...
#6: Post edited
- In this simple challenge, create a short program that takes 2 `int`s as input, output them, swap their places, then output them again. Those 2 integers can't be the same number. The program with the shortest solution wins! Loopholes are banned in this challenge.
- An example C program for the challenge (mostly ungolfed):
- ```c
- #include <stdio.h>
- int main() {
- int x, y;
- scanf("%i %i", &x, &y);
- printf("%i %i", x, y);
- int z = x;
- x = y;
- y = z;
- printf("%i %i", x, y);
- }
```
- In this simple challenge, create a short program that takes 2 `int`s as input, output them, swap their places, then output them again. Those 2 integers can't be the same number. The program with the shortest solution wins! Loopholes are banned in this challenge.
- An example C program for the challenge (mostly ungolfed):
- ```c
- #include <stdio.h>
- int main() {
- int x, y;
- scanf("%i %i", &x, &y);
- printf("%i %i", x, y);
- int z = x;
- x = y;
- y = z;
- printf("%i %i", x, y);
- }
- ```
- You can make 2 answers in one post: 1 with output swapping, and 1 with variable swapping.
#4: Post edited
In this simple challenge, create a short program that takes 2 `int`s as input, output them, swap their places, then output them again. Those 2 integers can't be the same number. The program with the shortest solution wins!However, you can't do something like:```print(x,y)print(y,x)```I'd call that a loophole. Loopholes are banned in this challenge.- An example C program for the challenge (mostly ungolfed):
- ```c
- #include <stdio.h>
- int main() {
- int x, y;
- scanf("%i %i", &x, &y);
- printf("%i %i", x, y);
- int z = x;
- x = y;
- y = z;
- printf("%i %i", x, y);
- }
- ```
- In this simple challenge, create a short program that takes 2 `int`s as input, output them, swap their places, then output them again. Those 2 integers can't be the same number. The program with the shortest solution wins! Loopholes are banned in this challenge.
- An example C program for the challenge (mostly ungolfed):
- ```c
- #include <stdio.h>
- int main() {
- int x, y;
- scanf("%i %i", &x, &y);
- printf("%i %i", x, y);
- int z = x;
- x = y;
- y = z;
- printf("%i %i", x, y);
- }
- ```
#2: Post edited
In this simple challenge, create a short program that takes 2 `int`s as input, output them, swap their places, then output them again. The program with the shortest solution wins!- However, you can't do something like:
- ```
- print(x,y)
- print(y,x)
- ```
- I'd call that a loophole. Loopholes are banned in this challenge.
- An example C program for the challenge (mostly ungolfed):
- ```c
- #include <stdio.h>
- int main() {
- int x, y;
- scanf("%i %i", &x, &y);
- printf("%i %i", x, y);
- int z = x;
- x = y;
- y = z;
- printf("%i %i", x, y);
- }
- ```
- In this simple challenge, create a short program that takes 2 `int`s as input, output them, swap their places, then output them again. Those 2 integers can't be the same number. The program with the shortest solution wins!
- However, you can't do something like:
- ```
- print(x,y)
- print(y,x)
- ```
- I'd call that a loophole. Loopholes are banned in this challenge.
- An example C program for the challenge (mostly ungolfed):
- ```c
- #include <stdio.h>
- int main() {
- int x, y;
- scanf("%i %i", &x, &y);
- printf("%i %i", x, y);
- int z = x;
- x = y;
- y = z;
- printf("%i %i", x, y);
- }
- ```
#1: Initial revision
Small integer swapping
In this simple challenge, create a short program that takes 2 `int`s as input, output them, swap their places, then output them again. The program with the shortest solution wins! However, you can't do something like: ``` print(x,y) print(y,x) ``` I'd call that a loophole. Loopholes are banned in this challenge. An example C program for the challenge (mostly ungolfed): ```c #include <stdio.h> int main() { int x, y; scanf("%i %i", &x, &y); printf("%i %i", x, y); int z = x; x = y; y = z; printf("%i %i", x, y); } ```