Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
야
야오지앙_ITE1015_2019021503
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
야오지앙
야오지앙_ITE1015_2019021503
Commits
2e5f664b
Commit
2e5f664b
authored
Sep 20, 2022
by
야오지앙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
a8118638
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
3-1-3.cpp
3-1-3.cpp
+70
-0
No files found.
3-1-3.cpp
0 → 100644
View file @
2e5f664b
#include<iostream>
#include<string>
#include<algorithm>
using
namespace
std
;
#define n 10
string
dezero
(
string
a
)
{
long
int
i
;
for
(
i
=
0
;
i
<
a
.
length
();
i
++
)
{
if
(
a
.
at
(
i
)
>
48
)
break
;
}
if
(
i
==
a
.
length
())
return
"0"
;
a
.
erase
(
0
,
i
);
return
a
;
}
string
add
(
string
a
,
string
b
)
{
a
=
dezero
(
a
);
b
=
dezero
(
b
);
string
c
;
string
d
=
"0"
;
long
int
kmin
,
kmax
,
i
;
reverse
(
a
.
begin
(),
a
.
end
());
reverse
(
b
.
begin
(),
b
.
end
());
if
(
a
.
length
()
>
b
.
length
())
{
kmin
=
b
.
length
();
kmax
=
a
.
length
();
c
=
a
;
}
else
{
kmin
=
a
.
length
();
kmax
=
b
.
length
();
c
=
b
;
}
c
.
insert
(
c
.
length
(),
d
);
for
(
i
=
0
;
i
<
kmin
;
i
++
)
{
if
(
a
.
at
(
i
)
>=
48
&&
a
.
at
(
i
)
<=
57
)
a
.
at
(
i
)
-=
48
;
if
(
a
.
at
(
i
)
>=
97
&&
a
.
at
(
i
)
<=
122
)
a
.
at
(
i
)
-=
87
;
if
(
b
.
at
(
i
)
>=
48
&&
b
.
at
(
i
)
<=
57
)
b
.
at
(
i
)
-=
48
;
if
(
b
.
at
(
i
)
>=
97
&&
b
.
at
(
i
)
<=
122
)
b
.
at
(
i
)
-=
87
;
c
.
at
(
i
)
=
a
.
at
(
i
)
+
b
.
at
(
i
);
}
for
(
i
=
kmin
;
i
<
kmax
+
1
;
i
++
)
{
if
(
c
.
at
(
i
)
>=
48
&&
c
.
at
(
i
)
<=
57
)
c
.
at
(
i
)
-=
48
;
if
(
c
.
at
(
i
)
>=
97
&&
c
.
at
(
i
)
<=
122
)
c
.
at
(
i
)
-=
87
;
}
for
(
i
=
0
;
i
<
kmax
;
i
++
)
{
if
(
c
.
at
(
i
)
>=
n
)
{
c
.
at
(
i
+
1
)
+=
c
.
at
(
i
)
/
n
;
c
.
at
(
i
)
=
c
.
at
(
i
)
%
n
;
}
}
if
(
c
.
at
(
kmax
)
==
0
)
{
c
.
erase
(
kmax
,
kmax
+
1
);
}
for
(
i
=
0
;
i
<
c
.
length
();
i
++
)
{
if
(
c
.
at
(
i
)
>=
10
)
c
.
at
(
i
)
+=
87
;
if
(
c
.
at
(
i
)
<
10
)
c
.
at
(
i
)
+=
48
;
}
reverse
(
c
.
begin
(),
c
.
end
());
return
c
;
}
int
main
()
{
string
a
,
b
;
while
(
cin
>>
a
>>
b
)
{
cout
<<
add
(
a
,
b
);
}
return
0
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment