Compile Error
foo.cc: In function 'std::vector<int> add(std::vector<int>&, std::vector<int>&)': foo.cc:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 10 | for(int i = 0; i < a.size()|| i < b.size(); i++){ | ~~^~~~~~~~~~ foo.cc:10:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 10 | for(int i = 0; i < a.size()|| i < b.size(); i++){ | ~~^~~~~~~~~~ foo.cc:11:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 11 | if(i < a.size()) t += a[i]; | ~~^~~~~~~~~~ foo.cc:12:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 12 | if(i < b.size()) t += b[i]; | ~~^~~~~~~~~~ foo.cc: In function 'int main()': foo.cc:30:2: error: 'rerturn' was not declared in this scope 30 | rerturn 0; | ^~~~~~~
[Hydro](https://hydro.ac)提供评测服务
代码
#include<iostream>
#include<vector>
#include<string>
using namespace std;
vector<int> add(vector<int>& a, vector<int>& b){
int t = 0;
vector<int> c;
for(int i = 0; i < a.size()|| i < b.size(); i++){
if(i < a.size()) t += a[i];
if(i < b.size()) t += b[i];
c.push_back(t%10);
t/=10;
}
return c;
}
int main(){
string a,b;
cin >> a >> b;
vector<int> A,B;
for(int i = a.size()-1; i>=0; i--) A.push_back(a[i]-'0');
for(int i = b.size()-1; i>=0; i--) B.push_back(b[i]-'0');
vector<int> C = add(A,B);
for(int i = C.size() - 1; i>=0; i--) cout << C[i];
rerturn 0;
}
信息
- 递交者
- 类型
- 自测
- 题目
- P1020 [7FOJ]高精度加法
- 语言
- C++
- 递交时间
- 2022-06-17 16:34:10
- 评测时间
- 2022-06-17 16:34:10
- 评测机
- 分数
- 0
- 总耗时
- 0ms
- 峰值内存
- 0 Bytes