Variants
Views
Actions

Difference between revisions of "Cppreference:Archives"

From cppreference.com
Line 1: Line 1:
 
   
 
   
  
#include <iostream>
+
#include<cstdio>
#include <math.h>
+
#include<iostream>
 +
#include<vector>
 +
#include<cstring>
  
 
using namespace std;
 
using namespace std;
  
int main()
+
int lungime(string s) {
{
+
    return s.size();
int l12, l3, p, A, h;
+
}
cout<<"l1=l2=";
+
cin>>l12;
+
cout<<"l3=";
+
cin>>l3;
+
cout<<"h=";
+
cin>>h;
+
  
p=2*l12+l3;
+
bool CompareStart(string s1,char s) {
cout<<"Perimetrul triunghiului isoscel este: "<<p;
+
    if(s1[0] == tolower(s) || s1[0] == toupper(s)) {
A=(l3*h)/2;
+
        return true;
cout<<"\n"<<"Aria triunghiului isoscel este: "<<A;
+
    }
 +
    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


  1. include<cstdio>
  2. include<iostream>
  3. include<vector>
  4. 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;

}