Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include<time.h>
- #include<stdlib.h>
- int main()
- {
- int a[8]={2};
- for(int i=0;i<8;i++) a[i]=2;
- srand(time(NULL));
- int x = rand()%8 + 1;
- a[x-1] = 1;
- int i=0, j=0, k=0;
- int y1, y2, s1, s2;
- while(i<2) {
- s1=s2=0;
- printf("\nTry %d :\n", i+1);
- printf("How many items in left side? : ");
- scanf("%d", &y1);
- for(int i=0;i<y1;i++) {
- scanf("%d", &y2);
- s1+=a[y2-1];
- }
- printf("How many items in right side? : ");
- scanf("%d", &y1);
- for(int i=0;i<y1;i++) {
- scanf("%d", &y2);
- s2+=a[y2-1];
- }
- if(s1==s2) {
- printf("They are equal!");
- }
- else{
- printf("The weights are: %d and %d. They are not equal.", s1, s2);
- }
- i++;
- }
- printf("\nEnter your guess: ");
- scanf("%d", &k);
- if(k==x) printf("\nYou are absolutely right!");
- else printf("\nBetter luck next time! :V");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement