Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
What is the output of the given program:
#include <iostream>
#include <algorithm>
using namespace std;
int cnt=0; int Even=0; int sz[1000005]; int id[1000005]; void UF(int N) { cnt = N; for(int i=0; i<N; i++){ id[i] = i; sz[i] = 1; } }
int find(int p) { int root = p; while (root != id[root]) root = id[root]; while (p != root) { int newp = id[p]; id[p] = root; p = newp; } return root; } void merge(int x, int y) { int i = find(x); int j = find(y); if (i == j) return; if (sz[i] < sz[j]){ id[i] = j; if(sz[i]%2==0) Even--; int prev=sz[j]; sz[j] += sz[i]; cout<<"**"<<sz[i]<<" "<<prev<<" "<<sz[j]<<endl; if(sz[j]%2==0 && prev%2!=0) Even++; if(sz[j]%2!=0 && prev%2==0) Even--; } else { id[j] = i; if(sz[j]%2==0) Even--; int prev=sz[i]; sz[i] += sz[j]; cout<<"&&"<<sz[i]<<" "<<prev<<" "<<sz[j]<<endl; if(sz[i]%2==0 && prev%2!=0) Even++; if(sz[i]%2!=0 && prev%2==0) Even--; } cnt--; } bool connected(int x, int y){ return find(x) == find(y); } int count(){ return cnt; } int main() { int friends,Conn,A,B; cin>>Conn; UF(100005); char C; for(int i=0;i<Conn;i++){ cin>>C>>A>>B; if(C=='C') merge(A,B); else cout<<Even; cout<<endl; } return 0; }
C Assignment Curl library must be used To be done on linux, it should be compiled using the following command: gcc -Wall -ansi -pedantic NameOfFile.c -lncurses Please make sure it is commented with clarification Variable names in camel case
Create a Boolean function that computes the value of a factorial for values up to including 10. Include comments about how to use the function and describing how it works.
Write an interactive program that prompts for a desired sum, then repeatedly rolls two six-sided dice until their sum is the desired sum. Here is the expected dialogue with the user.
write a c programme to find the minimum and maximum value each elements in each row ,to create table b,having 5 rows and 2 coloums,the first coloum of table b is the maximumvalue and thye second coloum is the maximum value in each row.
write a function odd_fill() that fills all integers between two pointers, first and last, with a sequence of odd integers: 1,3,5,7
Write a program c that will find the smallest, largest and average values in a collection of N numbers.Get the value of N before scanning each value in the collection of N numbers.
Write the definitions of the functions to overload the operators defined in parts a to c and write a test program that tests various operations on the class rectangleType.
Use functional decomposition to solve this problem, and code the solution using functions wherever it makes sense to do so. Your program should check for invalid data such as nonpositive dimensions, number of rooms less than 1.
Write a C++ function that removes and counts all occurrences of a given string from such a bag. Your function should return this number.
Prepare a function called perfect(NUM) that determines if parameter NUM is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000.
Make a C++ program that helps the health visitor making the statistics and heights of the individual pupils,
Write a function called distance that takes two Points as arguments and returns the distance between them.
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd