Join Our Email Alerts-Subscribe
Important Note:Login & Check Your Email Inbox and Activate Confirmation Link



Enter Your Email :

Copyright Disclaimer:
Section 107 of the Copyright Act Fair Use Contents .
We are forwarding content link(s) from our website to content website & We are not serving any contents.
Main Source:Google.com.All the Content PDF link(s) is/are obtained from GoogleSearch
for the purpose of Education & Teaching Intention. Not for commercial purpose.
Technicalsymposium.com is not liable/responsible for any copyright issues.

Subset Sum Problem

#include<stdio.h>
#include<conio.h>
void subset(int,int,int);
int m,r1,x[25],k,r=0,s=0,w[25],i,n;
void main()
{
clrscr();
printf("\n\nSubset Sum Problem\n\n");
printf("\n\tEnter the maximum number of elements :");
scanf("%d",&n);
for(i=0;i<n;i++)
x[i] = 0;
for(i=0;i<n;i++)
{
printf("\n Enter the [%d] element ",i+1);
scanf("%d",&w[i]);
r=r+ w[i];
}
//r1 = r
printf("\n\tEnter the Sum :");
scanf("%d",&m);
subset(0,0,r);
getch();
}
void subset(int s,int k,int r)
{
x[k]=1;
if(s+w[k]==m)
{
printf("\nSolutions :");
for(i=0;i<n;i++)
{
if(x[i])
printf("\t%d",w[i]);
}
for(i=k+1;i<n;i++)
x[i]=0;
getch();
//r = r1;
}
else if(s+w[k]+w[k+1]<=m)
subset(s+w[k],k+1,r-w[k]);
if(s+r-w[k]>=m && s+w[k+1]<=m)
{
x[k]=0;
subset(s,k+1,r-w[k]);
}
}

 

Fresher Jobs & IT Jobs and Off-Campus

Programming & Projects PDF

Conferences & Symposium Details

B.E/Medical Lecture Notes PDF

GRE/TOEFL/IELTS/GMAT/SAT Notes

Aptitude/Placement Papers

Technicalsymposium.com-Contents

Technicalsymposium.com-Contents

Conference & Symposium Details

Government Jobs Details

Off-Campus Interviews & Walk-in/Career Pages

Software Jobs and IT Jobs Details

Bank Jobs & PO/Clerk Jobs Preparation Books PDF

Bank Quick Study Notes & Question Papers PDF

IES Syllabus & Question Papers-Free Download

Placement Papers with Answers PDF

Aptitude Study Notes & Puzzles PDF

Technical Interview Questions with Answers PDF





Technicalsymposium.com-Contents

Technicalsymposium.com-Contents

BE/B.Tech/M.Sc & B.Sc & Commerce Lecture Notes-Free Download

Engineering Maths Lecture Notes-Free Download

GRE Study Materials & Notes-Free Download

TOEFL Study Materials-Free Download.

IELTS Study Materials & ebooks-Free Download

GMAT Study Materials-Free Download

SAT Study Materials & ebooks-Free Download

Engineering Physics Lecture Notes-Free Download





Technicalsymposium.com-Contents

Technicalsymposium.com-Contents

Resume Formats and Resume Writing Tips

Group Discussion Topics & Answers

HR & Situational and Behavioral Interview Questions & Answers

General Job Interviews Materials-Free Download

Engineering Chemistry Lecture Notes-Free Download

Anna University Question Papers and Study Notes PDF

Programming & Manuals and Projects PDF

GATE Question Papers and Study Materials & ebooks PDF

All Engineering ebooks & Study Notes PDF

Paper Abstracts and Conference Papers PDF