Search
 
SCRIPT & CODE EXAMPLE
 

C

manasa loves maths solution IN C

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int val[10];
int flag = 0;
void permute(int i,int n)
    {
    int j,k,t;
    long int N;
    if(i == n)
    {
       N=0;
       for(k=0;k<=n;k++)
           N = N*10 + val[k];
       N = N % 1000;
       if(flag == 0)
           {
           if(N%8 == 0)
               flag =1;
       }
       //printf("%ld
",N);
    }
    else
        {
        for(j=i;j<=n;j++)
        {
        t=val[i];
        val[i]= val[j];
        val[j] = t;
           permute(i+1,n);
        t=val[i];
        val[i]= val[j];
        val[j] = t; 
        }
    }
}
int main() {
    int T;
    char ch[115];
    int arr[10]={0},i,j;
    long long int N;
    scanf("%d",&T); 
    while(T--)
        {
        N=0;
        for(i=0;i<10;i++)
            arr[i]=0;
        scanf("%s",ch);
        //printf("%s
",ch);
        //continue;
        for(i=0;i<strlen(ch);i++)
            {
            arr[ch[i]-48]=1;
        }
        j=0;
        for(i=0;i<10;i++)
            {
            //printf("%d ",arr[i]);
            if(arr[i] == 1)
              val[j++] = i; //N = N*10 + i;
        }
        //for(i=0;i<j;i++)
          //printf("%d ",val[i]);
       // break;
        flag = 0;
        //printf("%d
",flag);
        permute(0,j-1);
        //printf("%d
",flag);
        if(flag == 1)
            printf("YES
");
        else
            printf("NO
");
        //if(arr[0] == 1)
           // N = N*10;        
        //printf(" %lld
",N);
        //break;    
    }
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: taking input and converting it to a string in c 
C :: C #define preprocessor 
C :: wpdb add temporary while drop table 
C :: program to merge two strings in c 
C :: how much larger integer i can input in c language? 
C :: captive portal esp8266 
C :: reap zombie process in c 
C :: putting character in the begginig and end of sring C 
C :: user define 
C :: To get file info 
C :: qgraphicsscene save all items to file 
C :: how to get a string input in c 
C :: Write a c program to add two numbers without using addition operator. 
C :: array of string in c 
C :: c constants 
C :: filing in c 
Dart :: flutter remove debug flag 
Dart :: text overflow ellipsis flutter 
Dart :: flutter padding top and bottom 
Dart :: round to decimal places dart 
Dart :: type check of variable dart 
Dart :: taskkill dart 
Dart :: flutter analyze apk size 
Dart :: increase text size of Test flutter 
Dart :: generate method o dart list 
Dart :: dart try-catch 
Dart :: flutter tooltip height 
Dart :: flutter transform 
Dart :: dart init Map 
Dart :: drawerheader height flutter 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =