• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

練習用です。いろんなものがごちゃまぜです。


Commit MetaInfo

Revision7eda4c73050bf56c727468ec54b14f8f4cb6292b (tree)
Time2017-03-05 19:18:35
Authorbellyoshi <tccwas@gmai...>
Commiterbellyoshi

Log Message

string

Change Summary

Incremental Difference

--- /dev/null
+++ b/CPP/ITP1_9/a.cpp
@@ -0,0 +1,30 @@
1+#include <iostream>
2+#include <string>
3+#include <cstdlib>
4+#include <algorithm>
5+
6+using namespace std;
7+
8+char ToLower(char c){
9+ return tolower(c);
10+}
11+
12+void tolower(string &s){
13+ transform(s.begin(), s.end(), s.begin(), ToLower);
14+}
15+
16+int main(int argc, char *argv[]){
17+ string W;
18+ string Ti;
19+ getline(cin, W);
20+ tolower(W);
21+ int count = 0;
22+ while(1){
23+ cin >> Ti;
24+ if(Ti == "END_OF_TEXT")break;
25+ tolower(Ti);
26+ if(Ti == W)count++;
27+ }
28+ cout << count << endl;
29+ return 0;
30+}
--- /dev/null
+++ b/CPP/ITP1_9/b.cpp
@@ -0,0 +1,25 @@
1+#include <iostream>
2+#include <string>
3+
4+using namespace std;
5+
6+int main(int argc, char *argv[]){
7+
8+ while(1){
9+ string inputstr;
10+ //getline(cin, inputstr);
11+ cin >> inputstr;
12+ if(inputstr == "-")break;
13+ int count;
14+ cin >> count;
15+ string s = inputstr;
16+ for(int i= 0; i< count; i++){
17+ int h;
18+ cin >> h;
19+ int len = s.length();
20+ s = s.substr(h , len - h) + s.substr(0, h);
21+ }
22+ cout << s << endl;
23+ }
24+ return 0;
25+}
--- /dev/null
+++ b/CPP/ITP1_9/c.cpp
@@ -0,0 +1,25 @@
1+#include <iostream>
2+#include <string>
3+
4+using namespace std;
5+
6+int main(int argc, char *argv[]){
7+ int n;
8+ cin >> n;
9+ string s_hanako, s_taro;
10+ int p_hanako = 0;
11+ int p_taro = 0;
12+ for(int i = 0; i < n; i++){
13+ cin >> s_taro >> s_hanako;
14+ if (s_taro == s_hanako){
15+ p_hanako += 1;
16+ p_taro += 1;
17+ } else if (s_taro < s_hanako) {
18+ p_hanako += 3;
19+ } else if (s_taro > s_hanako) {
20+ p_taro += 3;
21+ }
22+ }
23+ cout << p_taro << " " << p_hanako << endl;
24+ return 0;
25+}
--- /dev/null
+++ b/CPP/ITP1_9/d.cpp
@@ -0,0 +1,31 @@
1+#include <iostream>
2+#include <string>
3+#include <algorithm>
4+
5+using namespace std;
6+
7+int main(int argc, char *argv[]){
8+ string str;
9+ cin >> str;
10+ int count;
11+ cin >> count;
12+ for(int i = 0; i < count; i++){
13+ string command;
14+ cin >> command;
15+ if (command == "replace"){
16+ int first,last;
17+ string replace_str;
18+ cin >> first >> last >> replace_str;
19+ str.replace(first, last - first + 1, replace_str);
20+ }else if(command == "reverse"){
21+ int first,last;
22+ cin >> first >> last;
23+ reverse(str.begin() + first, str.begin() + last + 1);
24+ }else if(command == "print"){
25+ int first, last;
26+ cin >> first >> last;
27+ cout << str.substr(first,last - first + 1) << endl;
28+ }
29+ }
30+ return 0;
31+}
\ No newline at end of file
--- /dev/null
+++ b/CPP/ITP1_9/reverse.cpp
@@ -0,0 +1,11 @@
1+#include <iostream>
2+#include <string>
3+#include <algorithm>
4+
5+using namespace std;
6+
7+int main(int argc, char *argv[]){
8+ string str = "abcde";
9+ reverse(str.begin(), str.end());
10+ cout << str << endl;
11+}