C++, 68 bytes (-9 by ceilingcat, and -1 yet again by Mukundan314)
#import<iostream>
main(int c){for(std::cin>>c;~c;)putchar(49^!c--);}
I'm…not even going to try to explain this. Ooh, XOR!
C++ (gcc), 78 bytes (-4 thanks to Mukundan314)
#include<iostream>
int main(){int c;for(std::cin>>c;c--;)puts("1");puts("0");}
Similar idea to the original, but using for
loops and puts
.
C++ (gcc), 82 bytes (OG)
#include<iostream>
int main(){int n;std::cin>>n;std::cout<<std::string(n,'1')<<0;}
C++ syntax highlighting doesn't work. :(
Explanation
#include<iostream>
int main(){int n;std::cin>>n;std::cout<<std::string(n,'1')<<0;}
#include<iostream> # Imports the I/O library (char* haters be mad)
int main(){ } # Initiates the main() function.
int n;std::cin>>n; # Initializes variable n and reads it from STDIN.
std::cout<< # Prints things to STDOUT.
std::string(n,'1') # This constructs a string with the char '1' repeated n times.
<<0; # Appends a 0 and ends the final line.
💎
Created with the help of Luminespire.