You are on page 1of 4

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment 2.3
Student Name: Shashi Ranjan Mehta UID: 21BCS7093
Branch:BE-CSE Section/Group: IoT-624
Semester:5 Date of Performance:29-09-2023
Subject Name: Advance Programming Lab
Subject Code: 21CSP-314

1. Aim:
1.WAP to separate a number
2.WAP to pangram string
2. Objective:
1. Perform queries where each query consists of some integer string . For each query, print
whether or not the string is beautiful on a new line. If it is beautiful, print YES x, where is the
first number of the increasing sequence. If there are multiple such values of , choose the smallest.
Otherwise, print NO.
2. A pangram is a string that contains every letter of the alphabet. Given a sentence determine
whether it is a pangram in the English alphabet. Ignore case. Return either pangram or not
pangram as appropriate.

3. Script and Output:


Program 1:-
#include <bits/stdc++.h>
using namespace std;
int main(){
int q;
cin >> q;
for(int a0 = 0; a0 < q; a0++){
string s;
cin >> s;
// your code goes here
bool poss=false;
long long int ans=0;
if(s[0]=='0'){
string ns="0";
long long int next=1;
while(ns.size()<s.size()){
ns+=to_string(next);
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

next++;
}
if(ns==s) poss=true;
}
else{
for(int i=1;i<=(s.size()/2);i++){
ans*=10;
ans+=(s[i-1]-'0');
long long int next=ans+1;
string ns=s.substr(0,i);
while(ns.size()<s.size()){
ns+=to_string(next);
next++;
}
if(ns==s){
poss=true;
break;
}
}
}
if(poss&&s.size()>1) cout<<"YES "<<ans<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
Output:-
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Program 2:-
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define float long double
#define LL long long
#define itn int
#define mp make_pair
#define x first
#define y second
using namespace std;
int main(){
string s;
vector<int> a(256, 0);
getline(cin, s);
for (int i = 0; i < s.length(); i++){
a[s[i]]++;
}
for (char c = 'a'; c <= 'z'; c++){
if (a[c] + a[c - 'a' + 'A'] == 0){
cout << "not pangram\n";
return 0;
}
}cout << "pangram\n";
return 0;}
Output:-
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

You might also like