C, c + + code format optimization software

Source: Internet
Author: User

When the topic is not done or the algorithm can not be implemented, we naturally go to the Internet search code, but the online code layout is too messy, do not follow the code specification, for example: You can click this link http://tieba.baidu.com/f?kz=825544513, there's a code here,#include <iostream>#include<string.h>using namespacestd;intMain () {Chara[ -],b[ +];intk,i,j,t=0, LA,LB;SCANF ("%d",&k); while(t<k) {scanf ("%s", a); scanf ("%s", B);p rintf ("Case %d:\n",++t);p rintf ("%s +%s =", A, b); La=strlen (a); LB=strlen (b);Charc[ +]; if(la<lb)     {strcpy (c,a);     strcpy (A, b); strcpy (b,c);intC=la;     la=lb; lb=C;} for(i=0; i<la/2;++i) {intc=a[i]- -; A[i]=a[la-i-1]- -; A[la-i-1]=C; }    if(la&1) a[la/2]-= -; for(j=0; j<lb/2;++j) {     intc=b[j]- -; B[j]=b[lb-j-1]- -; b[lb-j-1]=C;} if(lb&1) b[lb/2]-= -;BOOLflag=0;  for(i=lb;i<=la;++i) b[i]=0; for(i=0; i<la;++i) {C[i]=a[i]+b[i]+Flag;flag=c[i]/Ten; c[i]=c[i]%Ten;} if(flag) cout<<1;  for(i=la-1; i>=0;--i) printf ("%d", C[i]); cout<<Endl;if(t!=k) cout<<Endl;}return 0;} How about copying the code?? This code a look on the annoyance, a little format is not, he asked for more than a year,, no one answer, estimated that is the reason. But what if this is the code we need?? 1.1 points to make up the space, quite troublesome, if the code longer point, hundreds of thousands of lines, estimated that no one will have patience to look at this code is the origin of the problem. In order to solve this problem, I specifically wrote this software, if only indentation, this simple, I think, since the writing, it is perfect to the best. After we entered the software company, it is estimated that the first to get a code specification (about code specifications, you can go to this site to see http://wenku.baidu.com/view/f6a3341dfc4ffe473368abce.html) Code specification is very important, because in the company, most of the time is used to look at other people's code, if written a bunch of mess, how will the company want you?? There is a non-standard place deduction 100 yuan, the estimated wages are deducted. Some people write code for several years, habits can not be changed suddenly, how to do? Do you want to check the code again for the spec? Haha, my software comes in handy, you just use my software an optimization, immediately ugly duckling change Swan, a code on the norm came out, haha, is so useful! First look at the above code is optimized by my software effectCopy code # include<iostream>#include<string.h>using namespacestd;intMain () {Chara[ -], b[ +]; intK, I, j, t =0, LA, LB; scanf ("%d", &k);  while(T <k) {scanf ("%s", a); scanf ("%s", B); printf ("Case %d:\n", ++t); printf ("%s +%s =", A, b); La=strlen (a); LB=strlen (b); Charc[ +]; if(La <lb)     {strcpy (c, a);     strcpy (A, b);            strcpy (b, c); intc = LA;      La = lb; LB =C; }         for(i =0; I < la/2; ++i) {intc = a[i]- -; A[i]= a[la-i-1]- -; A[la-i-1] =C; }            if(la&1) a[la/2] -= -;  for(j =0; J < lb/2; ++j) {intc = b[j]- -; B[J]= b[lb-j-1]- -; B[LB-j-1] =C; }            if(lb&1) b[lb/2] -= -; BOOLFlag =0;  for(i = lb; I <= la; + +)i) b[i]=0;  for(i =0; I < LA; ++i) {C[i]= A[i] + b[i] +Flag; Flag= c[i]/Ten; C[i] = c[i]%Ten; }            if(flag) cout <<1;  for(i = la-1; I >=0; --i) printf ("%d", C[i]); cout<<Endl; if(t! =k) cout<<Endl; }    return 0;} How about copying the code?? It's not bad. To illustrate, my software is not only in the beginning of the header to fill the grid, more importantly, the code in the line format is also optimized, which some of the IDE can not be compared with the reference code format standards are fully optimized, such as "<= "=" "= =" ">=" "<<" ">>" + ""-"*" "/" "%" "! ="such as the symbol around the full space," [] "" () "and so on all the elimination of space, {} Strictly aligned," "" the contents of the quotation mark does not make changes, ensure that the output format is correct, and the code in the blank line Delete ... More details You can study the code, the following my labor results for free to everyone this article turns from: http://www.cnblogs.com/ma6174/archive/2011/12/06/2277998.html

C, c + + code format optimization software

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.