Set namuna char turidagi to’plam(set) berilgan
tarix 19.05.2023 ölçüsü 15,86 Kb. #117385
961-21 guruh dasturlash2
/******************************************************************************
Set namuna. char turidagi to’plam(set) berilgan. Undagi unli harflarni char turidagi A to’plamga, undoshlarini B to’plamga o‘zlashtiruvchi dastur tuzing
*******************************************************************************/
#include
#include
using namespace std ;
int main()
{
set s,unli,undosh;
int n;
cin>>n;
for(int i = 0; i char a;
cin>>a;
s.insert(a);
}
set::iterator i;
for(i=s.begin(); i!=s.end(); i++){
char a = *i;
if(a=='a' || a=='e'|| a=='u'|| a=='i' || a=='o') unli.insert(a);
else undosh.insert(a);
}
cout<<"Unli harflar: "< for(i=unli.begin(); i!=unli.end(); i++){
cout<<*i<<" ";
}
cout<<"\nUndosh harflar: "< for(i=undosh.begin(); i!=undosh.end(); i++){
cout<<*i<<" ";
}
}
Tub sonni aniqlasj:
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C , C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C , Assembly , HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include
#include
#include
using namespace std;
bool Tub(int n){
if(n==1) return false ;
for(int i = 2; i<=sqrt(n); i++){
if(n%i==0) return false;
}
return true;
}
int main()
{
multiset m;
int n;
cin>>n;
for(int i=0; i int a;
cin>>a;
m.insert(a);
}
multiset::iterator i;
for(i=m.begin(); i!=m.end(); i++){
if(Tub(*i)) cout<<*i<<" ";
}
} Dostları ilə paylaş: