C++ Code Formatting Demo 2


FormatCode Code Formatter is based on serveral powerful syntax parser engines so you can exactly control the appearance of your source code. Here is the code formatting demo of FormatCode C/C++ Code Formatter to prove the ability of code formatting functions of FormatCode:

   /* Before Code Formatting */

   #include  <stdio.h>
   #define   l "=================================================="
   #define   m "                                                  "
   int       _(
   float     x,
   float     y){
   return    x>=0&&x<50&&y>=0&&y<20;}
   int main  (){
   char      a[2][20][51],c[9][4][51][51],d[100];
   int       e,f,g,h=0,i,j=0,k,b=0,n[9],o[9],p[9],x[9],y[9],q[9],r,s,t;
   float     u[9],v[9],w[9],z[9];
   printf    ("i%s\033Yppppppppppppppppppp1G0",l);
   do sprintf(a[0][j],"%s",m,
   sprintf   (a[1][j],"%s",l));
   while     (++j<20);
   scanf     ("%d %d\n",&r,&s);
   gets      (d);
   do        {
   sscanf    (d,"%d %d %f %f %f %f %d %d %d",&o[b],&p[b],&u[b],&v[b],&w[b],
             &z[b],&x[b],&y[b],&q[b],j=n[b]=i=0);
   do do     c[b][i][j][x[b]]=!
   gets      (c[b][i][j]);
   while     (++j<y[b]);
   while     (++i<q[b]+(j=0)||!++b);}
   while     (
   gets      (d)||(i=t=e=f=0));
   do        {
   do strncpy(a[h][i],m,50);
   while     (++i<20||(i=0));
   do if     (t>=o[i]&&t<=p[i]&&!(k=j=0))
   do do if  (_(u[i]+k,v[i]+j))a[h][(
   int       )v[i]+j][(
   int       )u[i]+k]=c[i][n[i]][j][k];
   while     (++k<x[i]);
   while     (++j<y[i]+(k=0)||((++n[i]-q[i]||(n[i]=0)),u[i]+=w[i],v[i]+=z[i],0));
   while     (++i<b||(k=j=g=0));
   do do if  (a[1-h][j][k]!=a[h][j][k]){f-j&&
   printf    ("%dG0",j+1,e=0,g+=4);k&&e>k&&
   printf    ("0%d ",k,g+=4);k&&e<k&&k-e>1&&
   printf    ("%d ",k-e,g+=3);k&&e<k&&k-e==1&&
   printf    (" ",g++);
   printf    ("r%c",a[h][j][k],g+=2,e=k,f=j);}
   while     (++k<50);
   while     (++j<20+(k=0));
   do printf ("1G0",g+=3,e=f=0);
   while     (g<s);h=1-h;}
   while     (++t<=r+(i=0));
   return    !
   puts      ("");}


   /* After Code Formatting */

   #include <stdio.h>
   #define l "=================================================="
   #define m "                                                  "
   int _(float x, float y)
   {
     return x >= 0 && x < 50 && y >= 0 && y < 20;
   }

   int main()
   {
     char a[2][20][51], c[9][4][51][51], d[100];
     int e, f, g, h = 0, i, j = 0, k, b = 0, n[9], o[9], p[9], x[9],
       y[9], q[9], r, s, t;
     float u[9], v[9], w[9], z[9];
     printf("i%s\033Yppppppppppppppppppp1G0", l);
     do
       sprintf(a[0][j], "%s", m, sprintf(a[1][j], "%s", l));
     while (++j < 20);
     scanf("%d %d\n", &r, &s);
     gets(d);
     do
     {
       sscanf(d, "%d %d %f %f %f %f %d %d %d", &o[b], &p[b], &u[b],
         &v[b], &w[b], &z[b], &x[b], &y[b], &q[b], j = n[b] = i = 0);
       do
         do
           c[b][i][j][x[b]] = !gets(c[b][i][j]);
         while (++j < y[b]);
       while (++i < q[b] + (j = 0) || !++b);
     }
     while (gets(d) || (i = t = e = f = 0));
     do
     {
       do
         strncpy(a[h][i], m, 50);
       while (++i < 20 || (i = 0));
       do
         if (t >= o[i] && t <= p[i] && !(k = j = 0))
         do
           do
             if (_(u[i] + k, v[i] + j))
               a[h][(int)v[i] + j][(int)u[i] + k] = c[i][n[i]][j][k];
           while (++k < x[i]);
         while (++j < y[i] + (k = 0) || ((++n[i] - q[i] || (n[i] = 0)),
                u[i] += w[i], v[i] += z[i], 0));
       while (++i < b || (k = j = g = 0));
       do
         do
         if (a[1-h][j][k] != a[h][j][k])
         {
           f - j && printf("%dG0", j + 1, e = 0, g += 4);
           k && e > k && printf("0%d ", k, g += 4);
           k && e < k && k - e > 1 && printf("%d ", k - e, g += 3);
           k && e < k && k - e == 1 && printf(" ", g++);
           printf("r%c", a[h][j][k], g += 2, e = k, f = j);
         }
         while (++k < 50);
       while (++j < 20+(k = 0));
       do
         printf("1G0", g += 3, e = f = 0);
       while (g < s);
       h = 1-h;
     }
     while (++t <= r + (i = 0));
     return !puts("");
   }


Click here to preview the C/C++ Code Formatting Demo 1, C/C++ Code Formatting Demo 3 and C/C++ Code Formatting Demo 4.

With FormatCode C++ Code Formatters, you can format and transform any foreign C/C++ source code to meet your preferred coding style or any common code convention in several seconds!