Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- using namespace std;
- int cseId();
- int complexNumber();
- int stringMatch();
- int intFloat();
- int password();
- void menubar(){
- bool decision = true;
- while(decision){
- cout<<"1. cseId :\n";
- cout<<"2. complexNumber :\n";
- cout<<"3. stringMatch :\n";
- cout<<"4. intFloat :\n";
- cout<<"5. password :\n";
- string n;
- cin>>n;
- if(n == "1" ){
- int flag = cseId();
- if (flag ==1)
- cout<<"Accepted\n";
- else
- cout<<"Not Accepted\n";
- }
- else if(n == "2"){
- int flag = complexNumber();
- if (flag ==1)
- cout<<"Accepted\n";
- else
- cout<<"Not Accepted\n";
- }
- else if(n == "3"){
- int flag = stringMatch();
- if (flag ==1)
- cout<<"Accepted\n";
- else
- cout<<"Not Accepted\n";
- }
- else if(n == "4"){
- int flag = intFloat();
- if (flag ==1)
- cout<<"Accepted\n";
- else
- cout<<"Not Accepted\n";
- }
- else if(n == "5"){
- int flag = password();
- if (flag ==1)
- cout<<"Accepted\n";
- else
- cout<<"Not Accepted\n";
- }
- else{
- cout<<"Invalid input, enter again \n";
- }
- }
- }
- int main() {
- menubar();
- return 0;
- }
- int cseId(){
- cout<<"Enter CSE id\n";
- string id;
- cin>>id;
- if(id[0] == '0' && id[1]=='1' && id[2] == '1'){
- if(id[5] == '1' || id[5] == '2' || id[5] == '3'){
- if(!(id[6] == '0' && id[7] == '0' && id[8] == '0')){
- return 1;
- }
- }
- }
- return 0;
- }
- int complexNumber(){
- cout<<"Enter Complex Number\n";
- string id;
- cin>>id;
- if ((id[0] <= '9' && id[0] >='0') || (id[0] <= 'z' && id[0] >= 'a')) {
- if (id[1] == '+'){
- if(id[2] == 'i' || id[3] == 'i'){
- return 1;
- }
- }
- }
- return 0;
- }
- int stringMatch(){
- cout<<"Enter String\n";
- string id;
- cin>>id;
- if(id.size() <4)
- return 0;
- if(id[0] <= '9' && id[0] >='0'){
- if (id[1] <= 'Z' && id[1] >= 'A'){
- if (!(id[2] <= 'Z' && id[2] >= 'A') || !(id[2] <= 'z' && id[2] >= 'a') ){
- if (((id[3] <= 'Z' && id[3] >= 'A') || (id[3] <= 'z' && id[3] >= 'a') || (id[3] <= '9' && id[3] >= '0'))){
- return 1;
- }
- }
- }
- }
- return 0;
- }
- int intFloat(){
- cout<<"Enter Float number\n";
- string id;
- cin>>id;
- int len = id.length();
- for(int i=0; i<len; i++){
- if((id[i] <= 'z' && id[i] >= 'a')){
- return 0;
- }
- }
- if(id[len-1] == '.'){
- return 0;
- }
- return 1;
- }
- int password(){
- cout<<"Enter Password\n";
- string id;
- cin>>id;
- int len = id.length();
- int upper =0;
- int lower = 0;
- int number = 0;
- if(len < 8){
- return 0;
- }
- for(int i=0; i<len; i++){
- if((id[i] <= 'z' && id[i] >= 'a') ){
- lower++;
- }
- if((id[i] <= 'Z' && id[i] >= 'A') ){
- upper++;
- }
- if((id[i] <= '9' && id[i] >= '0') ){
- number++;
- }
- }
- if (lower == 0 || upper ==0 || number == 0){
- return 0;
- }
- if(!(id[len-1] !='@' || id[len-1] !='$' || id[len-1] !='#' || id[len-1] !='&')){
- return 0;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement