Repository navigation
Expand file tree
/
Copy path14_string.cpp
More file actions
121 lines (95 loc) · 2.27 KB
/
Copy path14_string.cpp
File metadata and controls
121 lines (95 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// #include <iostream>
// using namespace std;
// int main(){
// char name[20];
// cout<< "Enter Your Name : ";
// cin>> name;
// cout<< "My name is " << name;
// }
// counting length of a character
// #include <iostream>
// using namespace std;
// int main(){
// char name[20];
// int count = 0;
// cin>> name;
// for(int i = 0;name[i]!= '\0';i++){
// count++;
// }
// cout<< count;
// }
// Reversing an string
// #include <iostream>
// using namespace std;
// int main(){
// char reverse[20];
// cin>> reverse;
// int count = 0;
// for(int i = 0;reverse[i]!= '\0';i++){
// count++;
// }
// int s = 0;
// int e = count-1;
// while(s<e){
// swap(reverse[s++],reverse[e--]);
// }
// cout<<"The reversal array is : " << reverse << endl;
// cout<<"The length of array is : " << count;
// }
// Check palindrome for a string
// #include <iostream>
// using namespace std;
// bool checkpalindrome(char a[],int count){
// int s = 0;
// int e = count - 1;
// while(s <= e){
// if(a[s] != a[e]){
// return 0;
// }
// else{
// s++;
// e--;
// }
// }
// return 1;
// }
// int main(){
// char a[20];
// cin>>a;
// int count = 0;
// for(int i = 0;a[i]!= '\0';i++){
// count++;
// }
// cout<< checkpalindrome(a,count);
// }
// Maximum Occuring character in a string
// #include <iostream>
// using namespace std;
// char maxOccurence(string s){
// int arr[26] = {0};
// for(int i = 0; i < s.length(); i++){
// char ch = s[i];
// int n = 0;
// if(ch >= 'a' && ch <= 'z'){
// n = ch - 'a';
// }
// else{
// n = ch - 'A';
// }
// arr[n]++;
// }
// int max = 0 , ans = 0;
// for(int i = 0;i<26;i++){
// if(max < arr[i]){
// ans = i;
// max = arr[i];
// }
// }
// char final = 'a' + ans;
// return final;
// }
// int main(){
// string s;
// cin>> s;
// cout<< maxOccurence(s) << endl;
// }