标签:clu return set strong problems http math mat else
1048 数字加密 (20分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805276438282240
第一次提交:
错误原因:a的位数大于b时,b不足的位需要补0做运算!
第二次提交:
代码:
#include <iostream> #include <cstring> #include <string> #include <cmath> #include <algorithm> #include <cstdio> using namespace std; int main() { int a[102]={0},b[102]={0}; int i=1,j=1,k=1; char chr1[102],chr2[102]; int len1,len2,len; cin>>chr1>>chr2; len1=strlen(chr1); len2=strlen(chr2); for(i=len1-1;i>=0;i--) { a[k]=chr1[i]-‘0‘; k++; } for(i=len2-1;i>=0;i--) { b[j]=chr2[i]-‘0‘; j++; } if(len1>len2) len=len1; else len=len2; for(i=1;i<=len;i++) { if(i%2==1) b[i]=(b[i]+a[i])%13; else{ if(b[i]<a[i]) b[i]=b[i]-a[i]+10; else b[i]=b[i]-a[i]; } } for(i=len;i>=1;i--) { if(b[i]==10) cout<<"J"; else if(b[i]==11) cout<<"Q"; else if(b[i]==12) cout<<"K"; else cout<<b[i]; } return 0; }
标签:clu return set strong problems http math mat else
原文地址:https://www.cnblogs.com/jianqiao123/p/12231558.html