| #include< bits/stdc++.h > using namespace std; | |
| int main() { | |
| int t; | |
| string s; | |
| cin >> t; | |
| while(t--) { | |
| int ar[256]= {0}; | |
| cin >> s; | |
| for(char ch : s){ | |
| ar[ch]++; | |
| } | |
| for(char ch = 'a' ; ch <= 'z';ch++ ) { | |
| if(ar[ch] > 0) cout << ch << " = " << ar[ch] << endl; | |
| } | |
| if(t>=1)cout << endl; | |
| } | |
| return 0; | |
| } |
Showing posts with label cpp. Show all posts
Showing posts with label cpp. Show all posts
Sunday, October 13, 2019
Dimik oj - 15 - অক্ষর গণনা
Dimik oj - 14 অক্ষরের ঘনঘটা
#include < bits/stdc++.h >
using namespace std;
int main() {
int t;
string s;
char ch;
scanf("%d ",&t);
while(t--) {
getline(cin , s);
scanf("%c ",&ch);
size_t n = count(s.begin(), s.end(), ch);
if(n > 0){
cout << "Occurrence of " << "'" << ch <<"'" << " in '"
<< s << "' = " << n << endl;
}else {
cout << "'" << ch << "' is not present" << endl;
}
}
return 0;
}
Dimik oj - 12 ফ্যাক্টরিয়াল 100
#include < iostream >
using namespace std;
int main() {
int n, t;
cin >> n;
while(n--) {
cin >> t;
int ans = 0;
while(t > 0) {
ans += t/5;
t/=5;
}
cout << ans << endl;
}
return 0;
}
Monday, September 23, 2019
প্রোগ্রামিং সমস্যা 11 - [৫২ সমস্যা বই] গৌণিক / ফ্যাক্টরিয়াল
#include< iostream >
using namespace std;
long long int fact(int n)
{
if(n <= 1) return 1;
return n * fact(n-1);
}
int main() {
int n, t;
cin >> n;
while(n--) {
cin >> t;
cout << fact(t) << endl;
}
return 0;
}
Sunday, September 22, 2019
প্রোগ্রামিং সমস্যা 9 - [৫২ সমস্যা বই] পূর্ণবর্গ সংখ্যা
| #include< bits/stdc++.h > using namespace std; | |
| int main() { | |
| long n,tc; | |
| cin >> tc; | |
| while(tc--){ | |
| cin >> n; | |
| long int d = sqrt(n); | |
| if(d*d == n) cout << "YES" << endl; | |
| else cout << "NO" << endl; | |
| } | |
| return 0; | |
| } |
প্রোগ্রামিং সমস্যা 8 - [৫২ সমস্যা বই] ছোট থেকে বড়
| #include< bits/stdc++.h > using namespace std; | |
| int main() { | |
| int n; | |
| int ar[3]; | |
| cin >> n; | |
| for(int i = 1; i <= n; i++) { | |
| printf("Case %d: ",i); | |
| cin >> ar[0] >> ar[1] >> ar[2]; | |
| sort(ar,ar+3); | |
| cout << ar[0] << " " << ar[1] << " " << ar[2] << endl; | |
| } | |
| return 0; | |
| } |
প্রোগ্রামিং সমস্যা 7 - [৫২ সমস্যা বই] সংখ্যা গণনা
| #include< bits/stdc++.h > using namespace std; | |
| int main() | |
| { | |
| int tc; | |
| string s; | |
| scanf("%d ",&tc); | |
| while(tc--){ | |
| int ans = 0; | |
| getline(cin, s); | |
| stringstream line(s); | |
| string num; | |
| while (line >> num) { | |
| ans++; | |
| } | |
| cout << ans << endl; | |
| } | |
| return 0; | |
| } |
প্রোগ্রামিং সম6্যা 6 - [৫২ সমস্যা বই] যোগফল
| #include< iostream > using namespace std; | |
| int main() | |
| { | |
| int tc; | |
| string s; | |
| cin >> tc; | |
| while(tc--){ | |
| cin >> s; | |
| cout << "Sum = " << s[0]-'0' + s[4]-'0' << endl; | |
| } | |
| return 0; | |
| } |
প্রোগ্রামিং সমস্যা 5 - [৫২ সমস্যা বই] বাক্স-১
| #include< bits/stdc++.h > using namespace std; | |
| int main() { | |
| int tc,k; | |
| cin >> tc; | |
| for(int i = 1; i <= tc; i++) { | |
| cin >> k; | |
| for(int j = 1; j <= k; j++){ | |
| for(int p = 1; p <= k; p++){ | |
| cout <<"*"; | |
| } | |
| cout << endl; | |
| } | |
| if(i != tc) cout << endl; | |
| } | |
| return 0; | |
| } |
প্রোগ্রামিং সমস্যা 4 - [৫২ সমস্যা বই] ভাজক
| #include< iostream > using namespace std; | |
| int main() { | |
| int tc,k; | |
| cin >> tc; | |
| for(int i = 1; i <= tc; i++) { | |
| cin >> k; | |
| cout << "Case " << i << ": "; | |
| for(int j = 1; j <= k/2; j++){ | |
| if(k%j == 0) cout << j << " "; | |
| } | |
| cout << k << endl; | |
| } | |
| return 0; | |
| } |
Subscribe to:
Comments (Atom)