Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

C (gcc), (削除) 115 (削除ここまで) (削除) 112 (削除ここまで) (削除) 109 (削除ここまで) (削除) 107 (削除ここまで) 104 bytes

f(n,s,l,p,d)char*s;{d=n<0?-1:1;do for(l=1,p=0;p>=0;p+=l)s[p]?d==l&&putchar(s[p]):l--;while(!n||(n-=d));}

Try it online!

Who said, we need strlen?

C (gcc), 115 bytes (134 with #include<string.h> in front)

#include<string.h>
f(n,s)char*s;{int l=strlen(s),d=n<0?0:2,m=d--,p;do for(p=m?0:l-1;p!=(m?l:-1);p+=d)putchar(s[p]);while(!n||(n-=d));}

Try it online!

Without #include<string.h> we get an implicit prototype for strlen that returns int, but strlen is size_t (at least nowadays, not perfectly sure about k&r or c89, but I believe, it returned int in the old days).

The missing #include <stdio.h> isn't a problem, because due to integer promotion, the default prototype will be int putchar(int) which is exactly what we want.

C (gcc), (削除) 115 (削除ここまで) (削除) 112 (削除ここまで) (削除) 109 (削除ここまで) (削除) 107 (削除ここまで) 104 bytes

f(n,s,l,p,d)char*s;{d=n<0?-1:1;do for(l=1,p=0;p>=0;p+=l)s[p]?d==l&&putchar(s[p]):l--;while(!n||(n-=d));}

Try it online!

Who said, we need strlen?

C (gcc), 115 bytes (134 with #include<string.h> in front)

#include<string.h>
f(n,s)char*s;{int l=strlen(s),d=n<0?0:2,m=d--,p;do for(p=m?0:l-1;p!=(m?l:-1);p+=d)putchar(s[p]);while(!n||(n-=d));}

Try it online!

Without #include<string.h> we get an implicit prototype for strlen that returns int, but strlen is size_t (at least nowadays, not perfectly sure about k&r or c89, but I believe, it returned int in the old days).

The missing #include <stdio.h> isn't a problem, because due to integer promotion, the default prototype will be int putchar(int) which is exactly what we want.

C (gcc), (削除) 115 (削除ここまで) (削除) 112 (削除ここまで) (削除) 109 (削除ここまで) (削除) 107 (削除ここまで) 104 bytes

f(n,s,l,p,d)char*s;{d=n<0?-1:1;do for(l=1,p=0;p>=0;p+=l)s[p]?d==l&&putchar(s[p]):l--;while(!n||(n-=d));}

Try it online!

Who said, we need strlen?

C (gcc), 115 bytes (134 with #include<string.h> in front)

#include<string.h>
f(n,s)char*s;{int l=strlen(s),d=n<0?0:2,m=d--,p;do for(p=m?0:l-1;p!=(m?l:-1);p+=d)putchar(s[p]);while(!n||(n-=d));}

Try it online!

Without #include<string.h> we get an implicit prototype for strlen that returns int, but strlen is size_t (at least nowadays, not perfectly sure about k&r or c89, but I believe, it returned int in the old days).

The missing #include <stdio.h> isn't a problem, because due to integer promotion, the default prototype will be int putchar(int) which is exactly what we want.

added 3 characters in body
Source Link

C (gcc), (削除) 115 (削除ここまで) (削除) 112 (削除ここまで) (削除) 109 (削除ここまで) 107(削除) 107 (削除ここまで) 104 bytes

f(n,s,l,p,d)char*s;{d=n<0?-1:1;do for(l=1,p=0;p>=0;p+=l)s[p]?d==l&&putchar(s[p]):(l=-l)--;while(!n||(n-=d));}

Try it online! Try it online!

Who said, we need strlen?

C (gcc), 115 bytes (134 with #include<string.h> in front)

#include<string.h>
f(n,s)char*s;{int l=strlen(s),d=n<0?0:2,m=d--,p;do for(p=m?0:l-1;p!=(m?l:-1);p+=d)putchar(s[p]);while(!n||(n-=d));}

Try it online!

Without #include<string.h> we get an implicit prototype for strlen that returns int, but strlen is size_t (at least nowadays, not perfectly sure about k&r or c89, but I believe, it returned int in the old days).

The missing #include <stdio.h> isn't a problem, because due to integer promotion, the default prototype will be int putchar(int) which is exactly what we want.

C (gcc), (削除) 115 (削除ここまで) (削除) 112 (削除ここまで) (削除) 109 (削除ここまで) 107 bytes

f(n,s,l,p,d)char*s;{d=n<0?-1:1;do for(l=1,p=0;p>=0;p+=l)s[p]?d==l&&putchar(s[p]):(l=-l);while(!n||(n-=d));}

Try it online!

Who said, we need strlen?

C (gcc), 115 bytes (134 with #include<string.h> in front)

#include<string.h>
f(n,s)char*s;{int l=strlen(s),d=n<0?0:2,m=d--,p;do for(p=m?0:l-1;p!=(m?l:-1);p+=d)putchar(s[p]);while(!n||(n-=d));}

Try it online!

Without #include<string.h> we get an implicit prototype for strlen that returns int, but strlen is size_t (at least nowadays, not perfectly sure about k&r or c89, but I believe, it returned int in the old days).

The missing #include <stdio.h> isn't a problem, because due to integer promotion, the default prototype will be int putchar(int) which is exactly what we want.

C (gcc), (削除) 115 (削除ここまで) (削除) 112 (削除ここまで) (削除) 109 (削除ここまで) (削除) 107 (削除ここまで) 104 bytes

f(n,s,l,p,d)char*s;{d=n<0?-1:1;do for(l=1,p=0;p>=0;p+=l)s[p]?d==l&&putchar(s[p]):l--;while(!n||(n-=d));}

Try it online!

Who said, we need strlen?

C (gcc), 115 bytes (134 with #include<string.h> in front)

#include<string.h>
f(n,s)char*s;{int l=strlen(s),d=n<0?0:2,m=d--,p;do for(p=m?0:l-1;p!=(m?l:-1);p+=d)putchar(s[p]);while(!n||(n-=d));}

Try it online!

Without #include<string.h> we get an implicit prototype for strlen that returns int, but strlen is size_t (at least nowadays, not perfectly sure about k&r or c89, but I believe, it returned int in the old days).

The missing #include <stdio.h> isn't a problem, because due to integer promotion, the default prototype will be int putchar(int) which is exactly what we want.

added 4 characters in body
Source Link

C (gcc), (削除) 115 (削除ここまで) 112(削除) 112 (削除ここまで)(削除) 109 (削除ここまで) 107 bytes

f(n,s,l,p,d)char*s;{int l,d=n<0?-1:1,p,c;do1;do for(l=1,p=0;p>=0;p+=l)c=s[p],cs[p]?d==l&&putchar(cs[p]):(l=-l);while(!n||(n-=d));}

Try it online! Try it online!

Who said, we need strlen?

C (gcc), 115 bytes (134 with #include<string.h> in front)

#include<string.h>
f(n,s)char*s;{int l=strlen(s),d=n<0?0:2,m=d--,p;do for(p=m?0:l-1;p!=(m?l:-1);p+=d)putchar(s[p]);while(!n||(n-=d));}

Try it online!

Without #include<string.h> we get an implicit prototype for strlen that returns int, but strlen is size_t (at least nowadays, not perfectly sure about k&r or c89, but I believe, it returned int in the old days).

The missing #include <stdio.h> isn't a problem, because due to integer promotion, the default prototype will be int putchar(int) which is exactly what we want.

C (gcc), (削除) 115 (削除ここまで) 112 bytes

f(n,s)char*s;{int l,d=n<0?-1:1,p,c;do for(l=1,p=0;p>=0;p+=l)c=s[p],c?d==l&&putchar(c):(l=-l);while(!n||(n-=d));}

Try it online!

Who said, we need strlen?

C (gcc), 115 bytes (134 with #include<string.h> in front)

#include<string.h>
f(n,s)char*s;{int l=strlen(s),d=n<0?0:2,m=d--,p;do for(p=m?0:l-1;p!=(m?l:-1);p+=d)putchar(s[p]);while(!n||(n-=d));}

Try it online!

Without #include<string.h> we get an implicit prototype for strlen that returns int, but strlen is size_t (at least nowadays, not perfectly sure about k&r or c89, but I believe, it returned int in the old days).

The missing #include <stdio.h> isn't a problem, because due to integer promotion, the default prototype will be int putchar(int) which is exactly what we want.

C (gcc), (削除) 115 (削除ここまで) (削除) 112 (削除ここまで)(削除) 109 (削除ここまで) 107 bytes

f(n,s,l,p,d)char*s;{d=n<0?-1:1;do for(l=1,p=0;p>=0;p+=l)s[p]?d==l&&putchar(s[p]):(l=-l);while(!n||(n-=d));}

Try it online!

Who said, we need strlen?

C (gcc), 115 bytes (134 with #include<string.h> in front)

#include<string.h>
f(n,s)char*s;{int l=strlen(s),d=n<0?0:2,m=d--,p;do for(p=m?0:l-1;p!=(m?l:-1);p+=d)putchar(s[p]);while(!n||(n-=d));}

Try it online!

Without #include<string.h> we get an implicit prototype for strlen that returns int, but strlen is size_t (at least nowadays, not perfectly sure about k&r or c89, but I believe, it returned int in the old days).

The missing #include <stdio.h> isn't a problem, because due to integer promotion, the default prototype will be int putchar(int) which is exactly what we want.

added 644 characters in body
Source Link
Loading
added 644 characters in body
Source Link
Loading
Source Link
Loading

AltStyle によって変換されたページ (->オリジナル) /