#include<iostream> using namespace std; main(){ int i=0; int s=0; char c; char r[500]; r[0]='\0'; c=getchar(); while(c!=-1){ while(i!=c){ if(i<c){ i++; r[s]='+'; s++; } else if(i>c){ i--; r[s]='-'; s++; } } r[s]='.'; r[s+1]='\0'; s=0; cout<<r; c=getchar(); } }
Note that non-ascii characters in the above source code will be escaped (such as \x9f).