# A0024 ## 描述 #### 給定一個由大小寫英文字母所組成的字串以及一個英文字母,請輸出字母在字串中出現的間隔距離。 ## 輸入 ```cpp= #include<bits/stdc++.h> #include<string> #include<iostream> using namespace std; int main() { string input; char target; int position[input.length()] , po_po = 0; cin >> input >> target; for(int i = 0 ; i<input.length() ; i++)//轉小寫 { int asc_code = (int)(input[i]); if(asc_code>=65 && asc_code<=90) { input[i] = (char)(asc_code +32); } } for(int i = 0 ; i<input.length() ; i++) { if( input[i] == target ) { position[po_po] = i; po_po += 1; } } for(int i = 0 ; i < po_po-1 ; i++) { if( i+1 < po_po -1){ cout << position[i+1] - position[i] << " " ; } else if( i+1 == po_po -1 ){ cout << position[i+1] - position[i] << endl; } } return 0; } ```