我的PAT-BASIC代码仓:https://github.com/617076674/PAT-BASIC

原题链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805262622244864

题目描述:

PAT-BASIC1076——Wifi密码

知识点:字符串

思路:按题述编程即可

时间复杂度是O(N)。空间复杂度是O(1)。

C++代码:

#include<iostream>
#include<string>

using namespace std;

int main(){
	int N;
	cin >> N;
	
	string options;
	
	int scores[4] = {1, 2, 3, 4};
	getchar();
	for(int i = 0; i < N; i++){
		getline(cin, options);
		for(int j = 0; j < options.length(); j++){
			if(options[j] == 'T'){
				cout << scores[options[j - 2] - 'A'];
				break;
			}
		}
	}
	
	return 0;
} 

C++解题报告:

PAT-BASIC1076——Wifi密码

 

相关文章:

  • 2021-04-28
  • 2021-05-09
  • 2021-12-03
  • 2021-04-22
  • 2021-04-23
  • 2021-12-05
  • 2021-08-10
  • 2021-11-24
猜你喜欢
  • 2022-01-15
  • 2021-04-07
  • 2021-10-16
  • 2021-05-18
  • 2021-10-05
  • 2021-05-23
  • 2021-09-14
相关资源
相似解决方案