• 个人简介

    高精度加

    #include<bits/stdc++.h> using namespace std; string add(string s1,string s2){ int arr[3000] = {0},brr[3000] = {0},crr[3000] = {0}; int cd1 = s1.size(); int cd2 = s2.size(); reverse(s1.begin(),s1.end()); reverse(s2.begin(),s2.end()); for(int i = 0;i < cd1;i++) arr[i] = s1[i] - '0'; for(int i = 0;i < cd2;i++) brr[i] = s2[i] - '0'; int cd3 = max(cd1,cd2); for(int i = 0;i<cd3;i++) crr[i] = arr[i] + brr[i]; for(int i = 0;i<cd3;i++){ if(crr[i] >= 10) { crr[i+1]++; crr[i] %= 10; } } if(crr[cd3]!=0) cd3++; reverse(crr,crr+cd3); string temp=""; for(int i = 0;i<cd3;i++) temp += char(crr[i]+'0'); return temp; } int main(){ string s1,s2; cin>>s1>>s2; cout<<add(s1,s2); return 0; }

    高精度减

    #include<bits/stdc++.h> using namespace std; int flag = 0; void jian(string s1,string s2){ int arr[3000] = {0},brr[3000] = {0},crr[3000] = {0}; int cd1 = s1.size(); int cd2 = s2.size(); reverse(s1.begin(),s1.end()); reverse(s2.begin(),s2.end()); for(int i = 0;i < cd1;i++) arr[i] = s1[i] - '0'; for(int i = 0;i < cd2;i++) brr[i] = s2[i] - '0'; int cd3 = max(cd1,cd2); for(int i = 0;i < cd3;i++){ if(arr[i]<brr[i]){ arr[i]+=10; arr[i+1]-=1; } crr[i] = arr[i] - brr[i]; } reverse(crr,crr+cd3); int l = 0; while(crr[l] == 0 && l < cd3-1)l++; if(flag == 1) cout<<"-"; for(int i = l;i<cd3;i++){ cout<<crr[i]; } } bool cmp(string s1,string s2){ if(s1==s2)return 1; if(s1.size() != s2.size()) return s1.size() > s2.size(); for(int i = 0;i<s1.size();i++){ if(s1[i] != s2[i]) return s1[i] > s2[i]; } } int main(){ string s1,s2; cin>>s1>>s2; if(cmp(s1,s2) == 0){ string temp = s1; s1 = s2; s2 = temp; flag = 1; } jian(s1,s2); return 0; }

    高精度乘

    #include<bits/stdc++.h> using namespace std; int flag = 0; void cheng(string s1,string s2){ int arr[30000] = {0},brr[30000] = {0},crr[30000] = {0}; int cd1 = s1.size(); int cd2 = s2.size(); reverse(s1.begin(),s1.end()); reverse(s2.begin(),s2.end()); for(int i = 0;i < cd1;i++) arr[i] = s1[i] - '0'; for(int i = 0;i < cd2;i++) brr[i] = s2[i] - '0'; for(int i=0;i<cd1;i++){ for(int j=0;j<cd2;j++){ crr[i+j]+=arr[i]*brr[j]; } } int cd3=cd1+cd2; for(int i=0;i<cd3;i++){ if(crr[i]>=10){ crr[i+1]+=crr[i]/10; crr[i]%=10; } } reverse(crr,crr+cd3); int l=0; while(crr[l]==0 && l<cd3-1)l++; string temp =""; for(int i=l;i<cd3;i++){ temp+=(char)(crr[i]+'0'); } cout<<temp; } int main(){ string s1,s2; cin>>s1>>s2; cheng(s1,s2); return 0; }

    判断回文

    #include<bits/stdc++.h> using namespace std;

    int main(){ string a; cin>>a; int cd=a.size(); a.replace(cd-1,1,""); string b=a; reverse(a.begin(),a.end()); if(a==b){ cout<<"TRUE"; }else{ cout<<"FALSE"; } return 0; }

    趣味填空

    #include<bits/stdc++.h> using namespace std; int GBXW(string a){ int hhh=0,cdd=a.size(); for(int u=0;u<cdd;u++){ hhh=hhh*10+(a[u]-'0'); } return hhh; } int main(){ int flag=0,uuu,llxx; string gbxw,wyf="",fxy="",lx=""; cin>>gbxw; int cd1=gbxw.size(); for(int i=0;i<cd1;i++){ if(gbxw[i]=='='){ uuu=i; break; } wyf+=gbxw[i]; } for(int i=uuu+1;i<cd1;i++){ lx+=gbxw[i]; } llxx=GBXW(lx); int cd2=wyf.size(); for(int u=0;u<cd2;cd2--){ fxy+=wyf[u]; wyf.replace(u,1,"");

    if(GBXW(wyf)+GBXW(fxy) == llxx){ flag=1; cout<<fxy<<"+"<<wyf<<"="<<lx; break; } } if(flag==0)cout<<"Impossible!"; return 0; }

    统计单词个数

    #include<bits/stdc++.h> using namespace std; int main(){ int sum=0; string s; while(cin>>s){

    sum++; } cout<<sum; return 0;

    }

    统计字符个数

    #include<bits/stdc++.h> using namespace std; string zf; int sum1,sum2,sum3; int main(){ cin>>zf; int cd=zf.size(); zf.replace(cd,1,""); for(int i=1;i<=cd;i++){ if(zf[i]>='A' && zf[i]<='Z'){ sum1++; } if(zf[i]>='a' && zf[i]<='z'){ sum2++; } if(zf[i]>='0' && zf[i]<='9'){ sum3++; } } cout<<sum1+1<<" "<<sum2<<" "<<sum3; return 0; }

    整数的拼接

    #include<bits/stdc++.h> using namespace std; string GBXW(int a){ string hhh=""; while(a>0){ hhh+=(char)(a%10+'0'); a/=10; } reverse(hhh.begin(),hhh.end()); return hhh; } bool bilbil(string a,string b){ return a+b<b+a; } int main(){ string gbxw[105]; int n; string mxt=""; cin>>n; for(int u=1;u<=n;u++){ cin>>gbxw[u]; } sort(gbxw+1,gbxw+1+n,bilbil); for(int u=n;u>=1;u--){ mxt+=gbxw[u]; } cout<<mxt; return 0; }

    成绩排序

    #include<bits/stdc++.h> using namespace std; struct stu{ int id,s,w,z; string m; }ar[150]; bool wym(stu a, stu b){ return a.z>b.z; } int main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>ar[i].id>>ar[i].m>>ar[i].s>>ar[i].w; ar[i].z=ar[i].s+ar[i].w; } for(int i=0;i<n;i++){ sort(ar,ar+n,wym); cout<<ar[i].m<<" "<<ar[i].z<<endl; } return 0; }

    大写英文字母个数

    #include<bits/stdc++.h> using namespace std;

    int main(){ int sum=0; string s; cin>>s; int cd=s.size(); s.replace(cd-1,1,""); for(int i=0;i<cd;i++){ if(s[i]>='A' && s[i]<='Z'){ sum++;

    } } cout<<sum; return 0;

    }

    高精度乘单精度

    #include<bits/stdc++.h> using namespace std; int flag = 0; void cheng(string s1,string s2){ int arr[30000] = {0},brr[30000] = {0},crr[30000] = {0}; int cd1 = s1.size(); int cd2 = s2.size(); reverse(s1.begin(),s1.end()); reverse(s2.begin(),s2.end()); for(int i = 0;i < cd1;i++) arr[i] = s1[i] - '0'; for(int i = 0;i < cd2;i++) brr[i] = s2[i] - '0'; for(int i=0;i<cd1;i++){ for(int j=0;j<cd2;j++){ crr[i+j]+=arr[i]*brr[j]; } } int cd3=cd1+cd2; for(int i=0;i<cd3;i++){ if(crr[i]>=10){ crr[i+1]+=crr[i]/10; crr[i]%=10; } } reverse(crr,crr+cd3); int l=0; while(crr[l]==0 && l<cd3-1)l++; string temp =""; for(int i=l;i<cd3;i++){ temp+=(char)(crr[i]+'0'); } cout<<temp; } int main(){ string s1,s2; cin>>s1>>s2; cheng(s1,s2); return 0; }

  • 通过的题目

  • 最近活动

题目标签

字符串
11
基础语法
6
结构体
5
简单循环
4
数论
4
素数判定
4
高精度
4
FFT
4
高精度算法
4
模拟
4
函数问题
3
数组问题
3
普及组
3
递归
2
noip
2
noip复赛
2
二维数组
2
函数
2
普及组二阶上测试题
2
2002
1