1.注意索引值越界
2.兩數相減小於0,可用abs處理,或用負號處理
#include <iostream>using namespace std;
int main(){ string s; cin >> s; for (int i=0;i<s.length() - 1;++i){ int num = s[i] - s[i+1]; if (num < 0){ num = -(num); } cout << num; } return 0;}