#35356: python ans


1360467-8@g.puiching.edu.mo (三國迷李牧粉)

學校 : 不指定學校
編號 : 189084
來源 : [202.86.172.163]
最後登入時間 :
2023-10-20 12:55:38
k629. Bit++ (位元++) | From: [60.246.51.183] | 發表日期 : 2023-05-28 17:57

a=int(input())
c=[]
d=0
for x in range(a):
    b=input()
    c.append(b)
for x in c:
    if x[1]=="+":
        d+=1
    else:
        d-=1
print(d)
 
#35411: Re: python ans


jeremydingeric@gmail.com (164253)

學校 : 臺北市立成功高級中學
編號 : 158900
來源 : [140.116.1.143]
最後登入時間 :
2024-04-02 13:37:11
k629. Bit++ (位元++) | From: [36.230.203.223] | 發表日期 : 2023-05-31 22:55

a=int(input())
c=[]
d=0
for x in range(a):
    b=input()
    c.append(b)
for x in c:
    if x[1]=="+":
        d+=1
    else:
        d-=1
print(d)


這大可直接

a=int(input())

d=0

for _ in range(a):

    if input()[1]=='+':d+=1

    else d-=1

print(d)

 
#35413: Re: python ans


jeremydingeric@gmail.com (164253)

學校 : 臺北市立成功高級中學
編號 : 158900
來源 : [140.116.1.143]
最後登入時間 :
2024-04-02 13:37:11
k629. Bit++ (位元++) | From: [36.230.203.223] | 發表日期 : 2023-05-31 23:02

這大可直接

a=int(input())

d=0

for _ in range(a):

    if input()[1]=='+':d+=1

    else d-=1

print(d)

@@沒看到倒數第二行else漏個:

 
ZeroJudge Forum