标签:des style ar io os sp for on div
Alice and BobTime Limit: 1 Sec Memory Limit: 64 MB
Submit: 255 Solved: 43
2 100 1000 100 110
100 10
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void mult(int p[],int *len1)
{
int i;
for(i=0;i<*len1;i++)
{
p[i]*=2;
p[i+1]+=p[i]/10;
p[i]%=10;
printf("p[%d]=%d\n",i,p[i]);
}
if(p[i])
(*len1)++;
}
void add(int p[],int q[],int *len1)
{
int i;
for(i=0;i<*len1;i++)
{
p[i]+=q[i];
if(p[i]>9)
{
p[i]-=10;
p[i+1]++;
}
}
if(p[i])
(*len1)++;
}
int main() //transfer binary to dimcal ,convey double"长度,十进制的数组"
{
freopen("a.txt","r",stdin);
int n,i,j;
char str1[1001];
char str2[1001];
int num_a[1000];
int num_b[1000];
int num_c[1000]; //两次出始化
int len1,len2;
scanf("%d",&n);
while(n--)
{
scanf("%s",str1);
scanf("%s",str2);
len2=len1=1;
memset(num_a,0,sizeof(num_a));
memset(num_b,0,sizeof(num_b));
memset(num_c,0,sizeof(num_c));
for(i=0;str1[i]!=‘\0‘;i++)
{
num_c[0]=str1[i]-‘0‘;
mult(num_a,&len1); //乘2
add(num_a,num_c,&len1);
}
for(i=0;str2[i]!=‘\0‘;i++)
num_a[i]=str2[i]-‘0‘;
}
return 0;
}
标签:des style ar io os sp for on div
原文地址:http://www.cnblogs.com/get-an-AC-everyday/p/4171045.html