Powered by:AB_IN 局外人
水一波博客。
A kiki算數
while True:
try:
a,b=map(int,input().split())
c=str(a+b)[-2:]
if c[-2]=='0':
print(c[-1])
else:
print(c)
except:
break
B 字母大小寫轉換
while True:
try:
s=input()
if s.islower()==True:
print(s.upper())
else:
print(s.lower())
except:
break
C 三角形判斷
while True:
try:
a,b,c=map(int,input().split())
if a+b>c and a+c>b and b+c>a:
if a==b!=c or a==c!=b or b==c!=a:
print("Isosceles triangle!")
elif a==b==c:
print("Equilateral triangle!")
else:
print("Ordinary triangle!")
else:
print("Not a triangle!")
except:
break
D 輸出學生信息
print("Name Age Gender")
print("---------------------")
print("Jack 18 man")
E 箭形圖案
總結規律即可。
while True:
try:
n = int(input())
for i in range(n + n + 1):
print(' ' * abs(n - i) + '*' * (1 + n - abs(n - i)))
except:
break
F 新年快樂
print("Happy New Year*2019*")
G 逆序輸出
s = input().split()
s.reverse()
print(' '.join(s))
H 有序序列判斷
input()
lst=list(map(int,input().split()))
tmp1=sorted(lst,reverse=True)
tmp2=sorted(lst)
if lst==tmp1 or lst==tmp2:
print("sorted")
else:
print("unsorted")
I 班級成績輸入輸出
*
會把s
中的值提出來,分別符合{}中輸出。
for i in range(5):
s= [eval(i) for i in input().split()]
print('{:.1f} {:.1f} {:.1f} {:.1f} {:.1f} {:.1f}'.format(*s,sum(s)))
J 上三角矩陣判定
#include <bits/stdc++.h>
using namespace std;
int n,a[300][300],t=0;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cin>>a[i][j];
if(j<i&&a[i][j]>0) t=1;
}
}
if(t==1)
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
return 0;
}
完結。