We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
大数相加C
/************************************************************************* > File Name: BigData.c > Author: > Mail: > Created Time: 一 4/23 16:20:30 2018 ************************************************************************/ #include<stdio.h> #include<string.h> int main(){ int sum[200]={0}; char arr[200]; while(~scanf("%s",arr)){ int len = strlen(arr); for(int i = len;i>0;i--){ sum[i] += arr[len-i] - '0'; } for(int i = 0;i<199;i++){ sum[i+1]+=sum[i]/10; sum[i]=sum[i]%10; } int lock = 0; for(int i = 199;i>0;i--){ if(sum[i]!=0){ lock = 1; } if(lock){ printf("%d",sum[i]); } } printf("\n"); } }
大数相加C语言优化版
#include<stdio.h> #include<string.h> int main(){ int sum[200]={0}; char arr[200]; while(~scanf("%s",arr)){ int len = strlen(arr); for(int i = len;i>0;i--){ sum[i] += arr[len-i] - '0'; } } for(int i = 0;i<199;i++){ sum[i+1]+=sum[i]/10; sum[i]=sum[i]%10; } int lock = 0; for(int i = 199;i>0;i--){ if(sum[i]!=0){ lock = 1; } if(lock){ printf("%d",sum[i]); } } printf("\n"); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
大数相加C
大数相加C语言优化版
The text was updated successfully, but these errors were encountered: