Skip to main content
added 149 characters in body
Source Link
Rames
  • 221
  • 1
  • 2

C 77

main(){int n;scanf("%d",&n);char c[]={n%4>1?'-':' ',~n%2?'1':'i',0};puts(c);}

Improved thanks to Ruslan

C 74-5=69

Oh and of course the most obvious approach

main(){unsigned n,*c[]={"1","i","-1","-i"};scanf("%d",&n);puts(c[n%4]);}

C 77

main(){int n;scanf("%d",&n);char c[]={n%4>1?'-':' ',~n%2?'1':'i',0};puts(c);}

Improved thanks to Ruslan

C 77

main(){int n;scanf("%d",&n);char c[]={n%4>1?'-':' ',~n%2?'1':'i',0};puts(c);}

Improved thanks to Ruslan

C 74-5=69

Oh and of course the most obvious approach

main(){unsigned n,*c[]={"1","i","-1","-i"};scanf("%d",&n);puts(c[n%4]);}
optimization thanks to Ruslan
Source Link
Rames
  • 221
  • 1
  • 2

C 8677

int main(){int n;scanf("%d",&n);char c[]={n%4>1?'-':' ',!(n%2)~n%2?'1':'i','\0'0};puts(c);}

Improved thanks to Ruslan

C 86

int main(){int n;scanf("%d",&n);char c[]={n%4>1?'-':' ',!(n%2)?'1':'i','\0'};puts(c);}

C 77

main(){int n;scanf("%d",&n);char c[]={n%4>1?'-':' ',~n%2?'1':'i',0};puts(c);}

Improved thanks to Ruslan

Source Link
Rames
  • 221
  • 1
  • 2

C 86

int main(){int n;scanf("%d",&n);char c[]={n%4>1?'-':' ',!(n%2)?'1':'i','\0'};puts(c);}