Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

Hello World | SBT | PROGRAMMING | DAILY TEST | 16 JUN

** CONTAINS ONLY TECHNICAL MCQ AND PROGRAMMING  **

 ** Click on the ads **


black flat screen computer monitor turned on near blue and white sky

 

TECHNICAL MCQ

1.  b

2.   b

3.    c

4.    a

5.    c

6.   a

7.   a

8.   c

9.   c

10.  c


*********************************************************************


PROGRAMMING

 Problem 1 :

Problem Statement
Petya loves football very much. One day, as he was watching a football match, he was writing the
players' current positions on a piece of paper. To simplify the situation he depicted it as a string
consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to
players of another team. If there are at least 7 players of some team standing one after another, then
the situation is considered dangerous. For example, the situation 00100110111111101 is dangerous and
11110111011101 is not. You are given the current situation. Determine whether it is dangerous or not.
Input Format
The first input line contains a non-empty string consisting of characters "0" and "1", which represents
players. There's at least one player from each team present on the field.
Output
Constraints
The length of the string does not exceed 100 characters.
Output Format
Print "YES" if the situation is dangerous. Otherwise, print "NO".

 

SOLUTION :

C CODE :

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char s[100];
int c=0,i,n;
gets(s);
puts(strstr(s,"1111111")||strstr(s,"0000000")?"YES":"NO");
return 0;
}
 


Problem 2 : 

Problem Statement
There are n stones on the table in a row, each of them can be red, green or blue. Count the minimum
number of stones to take from the table so that any two neighboring stones had different colors.
Stones in a row are considered neighboring if there are no other stones between them.
Input Format
The first line contains integer n— the number of stones on the table.
The next line contains string s, which represents the colors of the stones. We'll consider the stones in
the row numbered from 1 to n from left to right. Then the i-th character s equals "R", if the i-th stone is
red, "G", if it's green and "B", if it's blue.
Constraints
(1 ≤ n ≤ 50)
Output Format
Print a single integer — the answer to the problem

 

SOLUTION :

C++ CODE :

 

#include<iostream>
using namespace std;
int main()
{
    int n,i,j,sum=0;
    char s[100];
    cin >> n >> s;
    for (j=0,i = 1;i < n;i++,j++)
    {
        if (s[i] == s[j])/ / Check if the two adjacent characters are the same
        {
            sum++;
        }
    }
    cout<<sum;
}

 

 

Problem 3:

 Problem Statement
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word.
That's why he decided to invent an extension for his favorite browser that would change the letters'
register in every word so that it either only consisted of lowercase letters or, vice versa, only of
uppercase ones. At that as little as possible letters should be changed in the word. For example, the
word HoUse must be replaced with house, and the word ViP — with VIP. If a word contains an equal
number of uppercase and lowercase letters, you should replace all the letters with lowercase ones. For
example, maTRIx should be replaced by matrix. Your task is to use the given method on one given word.
Input Format
The first line contains a word s — it consists of uppercase and lowercase Latin letters and possesses
the length from 1 to 100.
Constraints
1<=length of word<=100
Output Format
Print the corrected word s. If the given word s has strictly more uppercase letters, make the word
written in the uppercase register, otherwise - in the lowercase one.

 

SOLUTION : 

PYTHON CODE: 

 s=input();print([s.lower(),s.upper()][sum(x<'['for x in s)*2>len(s)])

 

***********************************************************************

 

 


 

 



Post a Comment

Previous Post Next Post