#include<stdio.h>
#include<conio.h>
#define STMNT fscanf(fp,"%c",&ch)
void main()
{
FILE *fp;
int num_of_prednodes=0,cases=-1;
char ch;
clrscr();
fp=fopen("input.txt","r");
while(fscanf(fp,"%c",&ch)!=EOF)
{
if(ch=='i')
{
STMNT;
if(ch=='f')
{
num_of_prednodes++;
}
}
else if(ch=='w')
{
STMNT;
if(ch=='h')
{
STMNT;
if(ch=='i')
{
STMNT;
if(ch=='l')
{
STMNT;
if(ch=='e')
{
num_of_prednodes++;
}
}
}
}
}
else if(ch=='f')
{
STMNT;
if(ch=='o')
{
STMNT;
if(ch=='r')
{
num_of_prednodes++;
}
}
}
else if(ch=='c')
{
STMNT;
if(ch=='a')
{
STMNT;
if(ch=='s')
{
STMNT;
if(ch=='e')
{
cases++;
}
}
}
}
else if(ch=='d')
{
STMNT;
if(ch=='e')
{
STMNT;
if(ch=='f')
{
STMNT;
if(ch=='a')
{
cases++;
if(ch=='u')
{
STMNT;
if(ch=='l')
{
STMNT;
if(ch=='t')
{
cases++;
}
}
}
}
}
}
}
}
fclose(fp);
if(cases<=1)
{
num_of_prednodes+=cases;
printf("\nCyclometic Complexity is = Number of predicate nodes + 1");
printf("\n\t\t\t = %d + 1 = %d",num_of_prednodes,num_of_prednodes+1);
}
else
{
printf("\nCyclometic Complexity using predicate nodes cannot be applied to this graph...");
}
getch();
}
#include<conio.h>
#define STMNT fscanf(fp,"%c",&ch)
void main()
{
FILE *fp;
int num_of_prednodes=0,cases=-1;
char ch;
clrscr();
fp=fopen("input.txt","r");
while(fscanf(fp,"%c",&ch)!=EOF)
{
if(ch=='i')
{
STMNT;
if(ch=='f')
{
num_of_prednodes++;
}
}
else if(ch=='w')
{
STMNT;
if(ch=='h')
{
STMNT;
if(ch=='i')
{
STMNT;
if(ch=='l')
{
STMNT;
if(ch=='e')
{
num_of_prednodes++;
}
}
}
}
}
else if(ch=='f')
{
STMNT;
if(ch=='o')
{
STMNT;
if(ch=='r')
{
num_of_prednodes++;
}
}
}
else if(ch=='c')
{
STMNT;
if(ch=='a')
{
STMNT;
if(ch=='s')
{
STMNT;
if(ch=='e')
{
cases++;
}
}
}
}
else if(ch=='d')
{
STMNT;
if(ch=='e')
{
STMNT;
if(ch=='f')
{
STMNT;
if(ch=='a')
{
cases++;
if(ch=='u')
{
STMNT;
if(ch=='l')
{
STMNT;
if(ch=='t')
{
cases++;
}
}
}
}
}
}
}
}
fclose(fp);
if(cases<=1)
{
num_of_prednodes+=cases;
printf("\nCyclometic Complexity is = Number of predicate nodes + 1");
printf("\n\t\t\t = %d + 1 = %d",num_of_prednodes,num_of_prednodes+1);
}
else
{
printf("\nCyclometic Complexity using predicate nodes cannot be applied to this graph...");
}
getch();
}
Where is input file? In which format input should be taken? Please elaborate.
ReplyDelete