Difference between revisions of "Cppreference:Archives"
From cppreference.com
Line 1: | Line 1: | ||
− | #include <iostream> | + | #include<cstdio> |
− | #include < | + | #include<iostream> |
+ | #include<vector> | ||
+ | #include<cstring> | ||
using namespace std; | using namespace std; | ||
− | int | + | int lungime(string s) { |
− | { | + | return s.size(); |
− | + | } | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | bool CompareStart(string s1,char s) { | |
− | + | if(s1[0] == tolower(s) || s1[0] == toupper(s)) { | |
− | + | return true; | |
− | cout<<" | + | } |
+ | else return false; | ||
+ | } | ||
+ | |||
+ | bool CompareEnd(string s1,char f) { | ||
+ | if(s1[s1.size()-1] == tolower(f) || s1[s1.size()-1] == toupper(f)) { | ||
+ | return true; | ||
+ | } | ||
+ | else return false; | ||
+ | } | ||
+ | |||
+ | int main() { | ||
+ | vector<string>cuvinte; | ||
+ | string cuvant; | ||
+ | int nr1,nr2,i; | ||
+ | int s1=0,s2=0,s3=0; | ||
+ | char s,f; | ||
+ | cin>>s>>f; | ||
+ | cin>>nr1>>nr2; | ||
+ | while(cin>>cuvant) { | ||
+ | cuvinte.push_back(cuvant); | ||
+ | } | ||
+ | for(i=0;i<cuvinte.size();i++) { | ||
+ | if(cuvinte[i].size()<nr1 &&CompareStart(cuvinte[i],s)==1&&CompareEnd(cuvinte[i],f)==1) { | ||
+ | s1++; | ||
+ | } | ||
+ | if(CompareStart(cuvinte[i],s)==1&&CompareEnd(cuvinte[i],f)==1&&cuvinte[i].size()>=nr1&&cuvinte[i].size()<nr2) { | ||
+ | s2++; | ||
+ | } | ||
+ | if(CompareStart(cuvinte[i],s)==1&&CompareEnd(cuvinte[i],f)==1&&cuvinte[i].size()>=nr2) { | ||
+ | s3++; | ||
+ | } | ||
+ | } | ||
+ | cout<<s1<<" "<<s2<<" "<<s3<<endl; | ||
+ | return 0; | ||
} | } |
Revision as of 03:52, 16 January 2020
- include<cstdio>
- include<iostream>
- include<vector>
- include<cstring>
using namespace std;
int lungime(string s) {
return s.size();
}
bool CompareStart(string s1,char s) {
if(s1[0] == tolower(s) || s1[0] == toupper(s)) { return true; } else return false;
}
bool CompareEnd(string s1,char f) {
if(s1[s1.size()-1] == tolower(f) || s1[s1.size()-1] == toupper(f)) { return true; } else return false;
}
int main() {
vector<string>cuvinte; string cuvant; int nr1,nr2,i; int s1=0,s2=0,s3=0; char s,f; cin>>s>>f; cin>>nr1>>nr2; while(cin>>cuvant) { cuvinte.push_back(cuvant); } for(i=0;i<cuvinte.size();i++) { if(cuvinte[i].size()<nr1 &&CompareStart(cuvinte[i],s)==1&&CompareEnd(cuvinte[i],f)==1) { s1++; } if(CompareStart(cuvinte[i],s)==1&&CompareEnd(cuvinte[i],f)==1&&cuvinte[i].size()>=nr1&&cuvinte[i].size()<nr2) { s2++; } if(CompareStart(cuvinte[i],s)==1&&CompareEnd(cuvinte[i],f)==1&&cuvinte[i].size()>=nr2) { s3++; } } cout<<s1<<" "<<s2<<" "<<s3<<endl; return 0;
}