convert c 2b 2b code to c online

Solutions on MaxInterview for convert c 2b 2b code to c online by the best coders in the world

showing results for - "convert c 2b 2b code to c online"
Edoardo
19 Oct 2017
1
2#include <iostream>
3#include <string>
4
5using namespace std;
6
7bool isPolindrom(string s){
8  int len = s.length();
9  if (len < 2) return true; // if s == '' or s == <one symbol>   
10  bool condition = (s[0] == s[len-1]); // first symbol == last symbol
11  return condition && isPolindrom(s.substr(1, len-2)); // recursion
12} 
13
14int main()
15{
16  string name;
17  cout << "What is your word? ";
18  getline (cin, word);
19  cout << "it is" << (isPolindrom(word) ? " polindrom" : " not polindrom"); 
20}
Joanna
27 Nov 2017
1c program
Tyler
16 Sep 2018
1#include<bits/stdc++.h>
2using namespace std;
3int main()
4{
5    int T;
6    cin>>T;
7    while(T--)
8    {
9        int N,sum=1;
10        cin>>N;
11        if(N==1)
12        {
13            cout<<"1"<<endl;
14            continue;
15        }
16        while(sum*2<=N)
17        sum*=2;
18        int b=N-sum+1;
19        if(N==sum)
20        cout<<sum/2<<endl;
21        else
22        cout<<max(b,sum/2)<<endl;
23    }
24    return 0;
25}
Ian
23 Jul 2017
1#include <stdio.h>
2#include <math.h>
3#define COLUMN 6
4
5void createPattern(char pattern[][COLUMN],int numStudent,int row) {
6    for(int i = 0; i < row ; i++) {
7        for(int j = 0; j < COLUMN; j++) {
8            if(numStudent!=0) {
9                pattern[i][j] = 'X';
10                numStudent -- ;
11            }
12            else if(numStudent==0) {
13                pattern[i][j] = ' ';
14            }
15        }
16    }
17}
18
19void bookSeat(char pattern[][COLUMN],int rowB,int columnB) {
20    if(pattern[rowB-1][columnB-1] != ' ') {
21        pattern[rowB-1][columnB-1] = 'S';
22    }
23}
24
25void printPattern(char pattern[][COLUMN],int row) {
26    for(int i = 0; i < row ; i++) {
27        for(int j = 0; j < COLUMN; j++) {
28            printf("%c",pattern[i][j]);
29            if(j < COLUMN-1) {
30                printf(" ");
31            }
32        }
33        printf("\n");
34    }
35}
36int main() {
37    int numStudent,numSeat;
38    scanf("%d",&numStudent);
39    if(numStudent>=1 && numStudent<=40) {
40        int rowBook,columnBook;
41        int row = ceil((double)numStudent/COLUMN);
42        char pattern[row][COLUMN];
43        createPattern(pattern,numStudent,row);
44
45        scanf("%d",&numSeat);
46
47        for(int i = 0 ; i < numSeat ; i++) {
48            scanf("%d %d",&rowBook,&columnBook);
49            if((rowBook >= 1 && rowBook <= row ) && (columnBook >= 1 && columnBook <= COLUMN)) {
50                bookSeat(pattern,rowBook,columnBook);
51            }
52        }
53        printPattern(pattern,row);
54
55    }
56    else if(numStudent<1) {
57        printf("Students not enough.\n");
58    }
59    else if(numStudent>40) {
60        printf("Too many students.\n");
61    }
62    return 0;
63}
Pedro
12 Oct 2018
1#include <bits/stdc++.h>
2using namespace std;
3int recurFunct(int n)
4{
5    if (n==1)
6        return 1;
7    return recurFunct(n-1) + 2*n-1;
8}
9int main()
10{
11    int n;
12    cin>>n;
13    for (int i=2; i<=n+1; i++)
14    {
15        cout<<recurFunct(i)<<" ";
16        if (i%8 ==0 )
17            cout<<"\n";
18    }
19    return 0;
20}
Timote
21 Mar 2019
1include <iostream>
2using namespace std;
3int main(int argc, char** argv)
4{
5string s;
6int n,c=0,l;
7in>>s;
8cn>>n;
9l=s.length();
10while(l%n!=0)
11{
12s.append("*");
13l=s.length();
14}
15int i=0,t=0;
16while(i<l)
17    {
18    cout<<s[i];
19    c++;
20    if(c==n)
21    {
22    c=0;
23    cout<<"\n";
24    i=i+n;
25    t++;
26    }
27    else
28    {
29    if(t%2==0)
30    i++;
31    else
32    i--;
33    }
34}
35}
Joana
25 Aug 2017
1c programm
Nail
15 Aug 2017
1#include <bits/stdc++.h>
2using namespace std;
3 
4// Function to check if elements are
5// pairwise consecutive in queue
6bool pairWiseConsecutive(queue<int> q)
7{
8    // Transfer elements of q to aux.
9    stack<int> aux;
10    while (!q.empty()) {
11        aux.push(q.front());
12        q.pop();
13    }
14 
15    // Again transfer the
16    // elements of aux to aux2
17    stack<int> aux2;
18    while (!aux.empty()) {
19        aux2.push(aux.top());
20        aux.pop();
21    }
22 
23    // Traverse aux2 and see if
24    // elements are pairwise
25    // consecutive or not. We also
26    // need to make sure that original
27    // content is retained.
28    bool result = true;
29    while (aux2.size() > 1) {
30 
31        // Fetch current top two
32        // elements of aux2 and check
33        // if they are consecutive.
34        int x = aux2.top();
35        aux2.pop();
36 
37        int y = aux2.top();
38        aux2.pop();
39 
40        if (abs(x - y) != 1)
41            result = false;
42 
43        // Push the elements to queue
44        q.push(x);
45        q.push(y);
46    }
47 
48    if (aux2.size() == 1)
49        q.push(aux2.top());
50 
51    return result;
52}
53 
54// Driver program
55int main()
56{
57    // Pushing elements into the queue
58    queue<int> q;
59    q.push(4);
60    q.push(5);
61    q.push(-2);
62    q.push(-3);
63    q.push(11);
64    q.push(10);
65    q.push(5);
66    q.push(6);
67 
68    if (pairWiseConsecutive(q))
69        cout << "Yes" << endl;
70    else
71        cout << "No" << endl;
72 
73    // Printing the original queue
74    while (!q.empty()) {
75        cout << q.front() << " ";
76        q.pop();
77    }
78    cout << endl;
79 
80    return 0;
81}
Ariadna
10 Apr 2019
1#include<stdio.h>
2int main()
3{
4    int x;
5    
6    /* Print column names */
7    printf("Number\tSquare\tCube\n");
8    printf("=========================\n");
9
10    for(x=0; x<=20; x++)
11        printf("%d\t%d\t%d\n", x, x*x, x*x*x);
12    
13    return 0;
14}
Elena
12 Nov 2019
1#include<bits/stdc++.h>
2using namespace std;
3
4void printWords(string str)
5{
6	// word variable to store word
7	string word;
8
9	// making a string stream
10	stringstream iss(str);
11
12	// Read and print each word.
13	while (iss >> word){
14		reverse(word.begin(),word.end());
15		cout<<word<<" ";
16	}
17}
18
19// Driver code
20int main()
21{
22	string s = "GeeksforGeeks is good to learn";
23	printWords(s);
24	return 0;
25}
26// This code is contributed by Nikhil Rawat
27