资源描述:
《程序设计实验复杂代码.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#includeintmain(){intn;scanf("%d",&n);getchar();for(;n>0;n--){inta[10];scanf("%1d-%1d%1d%1d-%1d%1d%1d%1d%1d-%1d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);intsum=0;for(inti=0;i<9;i++)sum=sum+(a[i]*(i+1));if(sum%11==a[9])printf("Right");elsep
2、rintf("%d-%d%d%d-%d%d%d%d%d-%d",a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],sum%11);}return0;}#include#includevoidexch_str(char*s1,char*s2){chartmp[1001];strcpy(tmp,s1);strcpy(s1,s2);strcpy(s2,tmp);}intmain(){chara[1001],b[1001];inta1[1001]={0},b1[1
3、001]={0},s[1001]={0},sign=1;intlen_a,len_b,i,j,k=0,t;while(scanf("%s%s",a,b)!=EOF){;len_a=strlen(a);len_b=strlen(b);if(len_ab[i]){s
4、ign=1;break;}elseif(a[i]=0&&j>=0){s[k]=a1[i]-b1[j];//s[0]=0,因为a1[len_a]和b1[len_b]为0if(s[k]<0){a1[i-1]-=1;//借位s[k]+=10;}k++;i--;j--;}while(
5、i>=0){s[k]=a1[i];k++;i--;}if(sign<0)printf("-");while(s[k]==0&&k>0){k--;}if(k==0)printf("0");while(k>0){printf("%d",s[k]);k--;}printf("");}return0;}#include#include#defineMAX_LEN200intan1[MAX_LEN+10];intan2[MAX_LEN+10];charszLine1[MAX_LEN+10];charszL
6、ine2[MAX_LEN+10];intmain(){while(scanf("%s%s",szLine1,szLine2)!=EOF){inti,j,maxlen,max;memset(an1,0,sizeof(an1));memset(an2,0,sizeof(an2));intnLen1=strlen(szLine1);j=0;for(i=nLen1-1;i>=0;i--)an1[j++]=szLine1[i]-'0';intnLen2=strlen(szLine2);j=0;for(i=nLen2-1;i>=0;i--)an2[
7、j++]=szLine2[i]-'0';if(nLen1>nLen2)maxlen=nLen1;elsemaxlen=nLen2;for(i=0;i=10){an1[i]-=10;an1[i+1]++;}if(an1[i]!=0){max=i;}}for(i=max;i>=0;i--){printf("%d",an1[i]);}printf("");}return0;}#includeintmain(){inta,b,c,m,r,n,i;s
8、canf("%d",&n);for(i=1;i<=n;i++){scanf("%d%d%d",&a,&b,&c);do{r=a%b;a=b;b=r;}while(r!=0);do{m=a%c;a=c;c=m