Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
0
01_homework_daxiong
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
大雄
01_homework_daxiong
Commits
f355c932
Commit
f355c932
authored
Jan 17, 2019
by
大雄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改后的第一次作业
parent
33de32c3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
01-homework-daxiong.py
+7
-2
No files found.
01-homework-daxiong.py
View file @
f355c932
# 石头与宝石
# 给定字符串J 代表石头中宝石的类型,和字符串 S代表你拥有的石头。 S 中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石。 J 中的字母不重复,J 和 S中的所有字符都是字母。字母区分大小写,因此"a"和"A"是不同类型的石头。
# 示例 1: 输入: J = "aA", S = "aAAbbbb" 输出: 3
# 示例 2: 输入: J = "z", S = "ZZ" 输出: 0
# 注意: S 和 J 最多含有50个字母,J 中的字符不重复。
Jewels
=
input
(
"请输入宝石的类型
\n
"
)
Jewels
=
input
(
"请输入宝石的类型
\n
"
)
Stones
=
input
(
"请输入具有的石头为
\n
"
)
Stones
=
input
(
"请输入具有的石头为
\n
"
)
count
=
0
count
=
0
...
@@ -9,6 +13,7 @@ for i in range(len(Jewels)):
...
@@ -9,6 +13,7 @@ for i in range(len(Jewels)):
count
+=
1
count
+=
1
print
(
"
\n
"
)
print
(
"
\n
"
)
str
=
'
%
d'
%
count
# 将数字转化成字符串
str
=
'
%
d'
%
count
# 将数字转化成字符串
print
(
'石头中具有的宝石数目为'
+
str
)
# 如何换行后再输出count
# print('石头中具有的宝石数目为' + str) # 如何换行后再输出count
print
(
'石头中具有的宝石数目为'
,
count
)
print
(
'---------------'
)
print
(
'---------------'
)
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