題目傳動門
解決幾個點,這個問題就算解決了
輸入
求長度字母轉數字(負數負數負數)
還有乙個就是別自己加戲(比如我就習慣性的多輸入了很多空格)
#include
#include
#include
#include
#include
#include
using
namespace std;
int n;
intlen
(int a)
return tp;
}int
trans
(string chuan)
if(chuan[0]
=='-'
) tp *=-
1;return tp;
}int
main()
if(ss ==
"b")
if(ss ==
"c")
x =trans
(ss)
; cin >> ss;
y =trans
(ss);if
(sign ==
'+')
zong = x + y;
if(sign ==
'-')
zong = x - y;
if(sign ==
'*')
zong = x * y;
cout << x << sign << y <<
"="<< zong << endl <<
len(x)
+ len (y)
+len
(zong)+2
<< endl;
}return0;
}
洛谷 字串題單P1957 口算練習題
輸入格式 第一行為數值i 接著的i行為需要輸入的算式,每行可能有三個資料或兩個資料。若該行為三個資料則第乙個資料表示運算型別,a表示加法運算,b表示減法運算,c表示乘法運算,接著的兩個資料表示參加運算的運算數。若該行為兩個資料,則表示本題的運算型別與上一題的運算型別相同,而這兩個資料為運算數。輸出格...
洛谷 P1957 口算練習題
並不難的一條題目 就幾個點要注意 1.計算數字的長度時 要記得可能有負數 對負數要特殊處理 2.對於這種不是很難 操作卻略繁瑣的題目 要先將每一步在草稿紙上分析好 再寫 以便保持思路的清晰 特別是我這種思維混亂的人 p1957 口算練習題 include include include includ...
字串專題
created on 2019年12月1日 author hp 擷取字串 str2 我是迪迦奧特曼 str3 str2 5 str4 str2 0 len str2 2 print str3,str4 擷取的字串如果不存在,會出現異常,可以用try.except捕捉異常 try str5 str2 ...