#C - (削除) 95 (削除ここまで) 83 characters
C - (削除) 95 (削除ここまで) 83 characters
main(n,k){scanf("%d",&n);k=(n+9)%10;printf("%d%s\n",n,k<3?"st0円nd0円rd"+3*k:"th");}
Degolfed:
main(n,k)
{
scanf("%d",&n);
k=(n+9)%10; // xx1->0, xx2->1, xx3->2
printf("%d%s\n",n,k<3?"st0円nd0円rd"+3*k:"th");
}
We could do k=(n-1)%10 instead of adding 9, but for n=0 we would get an incorrect behaviour,
because in C (-1)%10 evaluates to -1, not 9.
#C - (削除) 95 (削除ここまで) 83 characters
main(n,k){scanf("%d",&n);k=(n+9)%10;printf("%d%s\n",n,k<3?"st0円nd0円rd"+3*k:"th");}
Degolfed:
main(n,k)
{
scanf("%d",&n);
k=(n+9)%10; // xx1->0, xx2->1, xx3->2
printf("%d%s\n",n,k<3?"st0円nd0円rd"+3*k:"th");
}
We could do k=(n-1)%10 instead of adding 9, but for n=0 we would get an incorrect behaviour,
because in C (-1)%10 evaluates to -1, not 9.
C - (削除) 95 (削除ここまで) 83 characters
main(n,k){scanf("%d",&n);k=(n+9)%10;printf("%d%s\n",n,k<3?"st0円nd0円rd"+3*k:"th");}
Degolfed:
main(n,k)
{
scanf("%d",&n);
k=(n+9)%10; // xx1->0, xx2->1, xx3->2
printf("%d%s\n",n,k<3?"st0円nd0円rd"+3*k:"th");
}
We could do k=(n-1)%10 instead of adding 9, but for n=0 we would get an incorrect behaviour,
because in C (-1)%10 evaluates to -1, not 9.
#C - (削除) 95 (削除ここまで) 83 characters
main(n,k){scanf("%d",&n);k=(n+9)%10;printf("%d%s\n",n,k<3?"st0円nd0円rd"+3*k:"th");}
Degolfed:
main(n,k)
{
scanf("%d",&n);
k=(n+9)%10; // xx1->0, xx2->1, xx3->2
printf("%d%s\n",n,k<3?"st0円nd0円rd"+3*k:"th");
}
We could do k=(n-1)%10 instead of adding 9, but for n=0 we would get an incorrect behaviour,
because in C (-1)%10 evaluates to -1, not 9.