If you can also use trigonometric functions, then there are several ways to do it.
If we can construct a graph like the following, which I will call $r(x)$ then $f(x)=r(x)+r(-x)$ will almost be what you want depending whether or not $f(2k)=1$ and $f(2k+1)=0$ for all integers $k$.
First, let us create a periodic "cutting" function
$$ c(x)=\lfloor1+\sin\pi x\rfloor $$
Now look at the graph of
$$ g(x)=\lceil x\rceil-x $$
If we multiply $g(x)$ and $c(x)$ we will get a function whose graph looks like the first graph above. So we define
\begin{eqnarray}
r(x)&=&g(x)c(x)\\
&=&(\lceil x\rceil-x)\lfloor1+\sin\pi x\rfloor
\end{eqnarray}
And let
\begin{eqnarray}
f_0(x)&=&r(x)+r(-x)\\
&=&(\lceil x\rceil-x)\lfloor1+\sin\pi x\rfloor+(\lceil -x\rceil+x)\lfloor1-\sin\pi x\rfloor
\end{eqnarray}
This function has the following graph
This is almost what we want, but we need to correct the missing points by adding a function which equals one for all even integers and equals zero elsewhere. A function such as
$$ c(x)=\left\lfloor\frac{1+\cos\pi x}{2}\right\rfloor $$
So we define
$$ f(x)=(\lceil x\rceil-x)\lfloor1+\sin\pi x\rfloor+(\lceil -x\rceil+x)\lfloor1-\sin\pi x\rfloor+\left\lfloor\frac{1+\cos\pi x}{2}\right\rfloor $$