-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.c
More file actions
44 lines (44 loc) · 715 Bytes
/
hello.c
File metadata and controls
44 lines (44 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <math.h>
int main()
{
int sum=0,n;
printf("Enter number of terms : ");
scanf("%d",&n);
printf("Enter numbers : ");
int num[n];
for(int i = 0;i<n;i++)
{
scanf("%d",&num[i]);
sum += num[i];
}
sum=sum/2;
for(int i = 0;i<pow(2,n);i++){
int current_sum = 0;
for(int j = 0;j<n;j++)
{
if(i&(1<<j))
{
current_sum+=num[j];
}
}
if(current_sum == sum)
{
for(int j =0;j<n;j++)
{
if(i&(1<<j))
{
printf("%d",num[j]);
}
}
}
printf("==");
for(int j = 0;j<n;j++)
{
if(!(i&(1<<j)))
{
printf("%d",num[j]);
}
}
printf("\n");}
}