c 2b 2b code to python code converter online

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

showing results for - "c 2b 2b code to python code converter online"
Angelo
15 Mar 2019
1#include<bits/stdc++.h>
2#include <iostream>
3
4using namespace std;
5
6
7struct n{
8    int d;
9    struct n*next;
10    };
11
12void push(struct n**headref, int new_d)
13{
14    struct n* new_node=new n;
15    new_node->d=new_d;
16    new_node->next=(*headref);
17    (*headref)=new_node;
18    }
19    
20    float avgofnodes(struct n*head)
21    {
22        if(!head){return -1;}
23        int c=0;
24        int s=0;
25        float avg =0.0;
26        struct n*now=head;
27        while(now!=NULL)
28        {
29            c++;
30            s+=now->d;
31            now=now->next;
32            }
33        avg=(double)s/c;
34        return avg;
35        }
36
37int main()
38{
39struct n*head=NULL;
40push(&head , 7);
41push(&head, 6);
42push(&head, 8);
43push(&head, 4);
44push(&head, 1);
45	cout<<"Average of nodes = "<<avgofnodes(head);
46return 0;	
47}
48
49
Elisa
31 Jan 2021
1#include <iostream>
2
3using namespace std;
4
5int main()
6
7{
8
9    int a = 5, b = 10, temp;
10
11    cout << "Before swapping." << endl;
12
13    cout << "a = " << a << ", b = " << b << endl;
14
15    temp = a;
16
17    a = b;
18
19    b = temp;
20
21    cout << "\nAfter swapping." << endl;
22
23    cout << "a = " << a << ", b = " << b << endl;
24
25    return 0;
26
27}
Jorge
13 Jun 2018
1#include<stdio.h>
2#include<conio.h>
3 
4void main()
5{
6    int i,j,k,n, sign = 1;
7    double det = 1; double temp;
8    double a[10][10],b[10][10];
9// Nhap cap cua ma tran:
10    printf("\nCap cua ma tran vuon, n = "); scanf("%d",&n);
11 
Leonardo
28 Apr 2017
1#include<iostream>
2#include<math.h>
3#define vL 0.4
4using namespace std;
5struct generator
6{
7    float IL,theat,Pout;
8};
9typedef struct generator GENERATOR;
10int main()
11{
12    int i=0,n;
13    float sum=0,avg,low,high,il,theat;
14    cout<<"Enter the value for 'n' : ";
15    cin>>n;
16    GENERATOR g[n];
17    
18    while(i<n)
19    {
20        cout<<"Enter Voltage and Current";
21        cin>>il>>theat;
22        if(il>0&&theat>=35&&theat<=45){
23        g[i].IL=il;
24        g[i].theat=theat;
25        g[i].Pout=sqrt(3)*il*cos(theat);
26        cout<<g[i].Pout;
27        
28        if(i==0)
29        {
30            low=g[i].Pout;
31            high=g[i].Pout;
32        }
33        ++i;
34        }else
35            cout<<"\nEnter Valid data(il>0 and theat>=-35 and theat<=45)";
36    }
37    i=1;
38    while(i<n)
39    {
40        if(low>g[i].Pout)
41            low=g[i].Pout;
42        if(high<g[i].Pout)
43            high=g[i].Pout;
44        sum+=g[i].Pout;
45        i++;
46    }
47    avg=sum/n;
48    cout<<"\nThe Lowest Output Power :"<<low;
49    cout<<"\nThe highest Output Power :"<<high;
50    cout<<"\nThe Average Output Power :"<<avg;
51    
52    
53}
54 OUTPUT
Serena
03 Feb 2016
1cout("HJello")
Filippo
15 Mar 2017
1#include <iostream>
2#include <bits/stdc++.h>
3using namespace std;
4int main()
5{
6    int num {};
7    vector <long double> list {};
8    long double sum {};
9    long double num_to_add {};
10    cout << "How many numbers do you want to add : ";
11    cin >> num;
12    for ( int i {1} ; i <= num ; ++i )
13    {
14        cout << "Enter the number " << i << "  : ";
15        cin >> num_to_add;
16        list.push_back(num_to_add);
17    }
18    for (int i {} ; i < num ; ++i)
19        sum += list[i];
20    cout << "\nTheir sum is : " << sum << endl;
21    list.clear();
22    return 0;
23}
Henri
29 Apr 2017
1void decrypt(string &text, string &key){
2	for(size_t i=0;i<text.length()-1;i++){
3		for (int j=0;j<26;j++){
4			if (text[i]==key[j]){
5				text[i]=j+97;
6				break;
7			}
8		}
9	}
10}
Sara
22 Mar 2018
1//*****************************************//
2
3//Main function 
4//Kristine Joy Barroso//
5//BSIT 2A
6
7//*****************************************//
8
9#include <iostream> 
10using namespace std; 
11
12//Function (1)
13int max_range(int side1, int side2)
14
15{
16	int range;
17	range= side1 + side2 - 1;
18	
19	return(range);
20}
21	
22//Function (2)
23int product(int Minutes, int Seconds) 
24
25{
26	int result;
27	result = Minutes * Seconds;
28	
29	return (result);
30}
31	
32//Function(3)
33long long convertDecimalToBinary(int n)
34{
35    long long binaryNumber = 0;
36    int remainder, i = 1, step = 1;
37
38    while (n!=0)
39    {
40        remainder = n%2;
41        cout << "Step " << step++ << ": " << n << "/2, Remainder = " << remainder << ", Quotient = " << n/2 << endl;
42        n /= 2;
43        binaryNumber += remainder*i;
44        i *= 10;
45    }
46    return binaryNumber;
47}
48//Main function
49int main() 
50
51{
52	int function;
53	
54	jump:
55	
56		cout<<"\nChoose Function number from (1-4): "
57		      "\n(1)Finds Triangle's Third Angle."
58		      "\n(2)Converts Minutes to Seconds."
59		      "\n(3)Converts Decimal to Binary"
60		      "\n(4)End Program\n"<<endl;
61		cin>>function;
62	
63	switch(function)
64	{
65		case 1:
66		{
67			int range;
68			int side1, side2;
69			
70			cout<<"Enter Side1: "<<endl;
71			cin>>side1;
72			cout<<"Enter Side 2: "<<endl;
73			cin>>side2;
74			
75			range=max_range(side1,side2);
76			cout<<"the maximum range is "<<range<<endl;
77			goto jump;
78		}
79		
80		case 2:
81		{
82				int Minutes;
83				int Seconds;
84				int result;
85				Seconds = 60;
86				
87				cout<<"Enter Minutes to be converted to seconds: "<<endl;
88				cin>>Minutes;
89				result= product(Minutes, Seconds);
90				cout<<"the result is "<<result<<endl;
91				goto jump;
92		}
93	
94	case 3:
95		{
96			int n, binaryNumber;
97			cout << "Enter a decimal number(0 - 255 only): ";
98			cin >> n;
99			binaryNumber = convertDecimalToBinary(n);
100			cout << n << " in decimal = " << binaryNumber << " in binary" << endl ;
101			goto jump;
102		}
103	case 4:
104	{
105		cout<<"PROGRAM END"<<endl;
106		return 0;
107	}
108	}
109}
Facundo
08 Nov 2018
1#include <bits/stdc++.h>
2
3using namespace std;
4
5vector<int>bfs(vector<int>*adj,int src,int k)
6{
7	if(k == 0)
8	{
9		vector<int>ans;
10		ans.push_back(src);
11		return ans;
12	}
13	
14	map<int,bool>visited;
15	map<int,int>level;
16	vector<int>ans;
17	queue<int>inserter;
18	inserter.push(src);
19	level[src] = 0;
20	while(!inserter.empty())
21	{
22		int z = inserter.front();
23		visited[z] = true;
24		inserter.pop();
25		for(int i = 0 ; i < adj[z].size(); i++)
26		{
27			if(!visited[adj[z][i]])
28			{
29				visited[adj[z][i]] = true;
30				inserter.push(adj[z][i]);
31				level[adj[z][i]] = level[z] + 1;
32				if(level[adj[z][i]] == k)
33					ans.push_back(adj[z][i]);
34				if(level[adj[z][i]] > k)
35					break;
36			}
37		}
38	}
39	return ans;
40}
41
42void solve()
43{
44	int target,m,n,sz;
45	vector<int>*adj;
46	cin>>sz;
47	adj = new vector<int>[sz + 1];
48	for(int i = 0 ; i < sz-1; i++)
49	{
50		int u,v;
51		cin>>u>>v;
52		adj[u].push_back(v);
53		adj[v].push_back(u);
54	}
55	cin>>target>>m;
56	vector<int>res = bfs(adj,target,m);
57	int x = res[0];
58	for(int i = 1 ; i < res.size(); i++)
59	{
60		x ^= res[i];
61	}
62	cout<<x<<endl;
63}
64int main()
65{
66	int t;
67	cin>>t;
68	while(t--)
69	{
70		solve();
71	}
72	return 0;
73}