You are on page 1of 3

#include <stdlib.

h>
#include <stdio.h>
int main()
{
char matrix[25][80];
int path[80],i=0,j,k=0; //matrix not defined
for(i=0;i<25;i++)
{
j=0;
while(matrix[i][j]=='*')
{
if(j==79)
{
printf("The path is:");
for(k=0;k<80;k++)
printf("%d ",path[k]);
printf("\n");
}
if(i<24)
{
if(matrix[i+1][j+1]=='*')
{i++;
j++;
path[k]=i;
k++;
}}
else if(matrix[i][j+1]=='*')
{
j++;
path[k]=i;
k++;
}
else if(i>0){
if(matrix[i-1][j+1]=='*')
{i--;
j++;
path[k]=i;
k++;
}
}
else{
break;
}
}
}
return 0;
}

#include<stdlib.h>
#include<stdio.h>
#include<string.h>
char warehause[50][20];
float pice[50];
int prod=0;
int insert_product()
{
char buffer[20];
float piceb;
int i;
printf("Enter name of product and its price.\n");
scanf("%s %f",buffer, &piceb);
for(i=0;i<50;i++)
{
if(strcmp(buffer,warehause[i])==0)
return 0;
}
if(prod==49)
return 2;
else
{strcpy(warehause[prod],buffer);
pice[prod]=piceb;
prod++;
return 1;
}
}
void print_all()
{
int i;
for(i=0;i<prod;i++)
printf("%s %0.1f\n",warehause[i],pice[i]);
}
int main()
{
int i,ret;
for(i=0;i<50;i++)
pice[i]=-2;
while(1)
{
printf("Press\n1-Insert new product\n2-Show list\n3-Exit\n");
scanf("%d",&i);
switch(i)
{
case 1 :
ret=insert_product();
if(ret==0)
printf("The name of a product must be or
iginal.\n");
if(ret==2)
printf("The list is full.\n");
if(ret==1)
printf("Done");
break;
case 2 :
print_all();
case 3 :
exit(0);
default :
printf("Not valid input.\n");
break;
}
getch();
}
return 0;
}
#include<stdio.h>
#include<stdio.h>
#include<string.h>
int main()
{
char file[50],dstat[20],astat[20],station[20];
int ds=0,as=0;
printf("Enter name of the file\n");
scanf("%s",file);
FILE *f;
printf("Enter the name of the staton.\n");
scanf("%s",station);
f=fopen("file","r");
while(fscanf(f,"%s %s %s %s",dstat,file,astat,file)==4);
{
if(strcmp(station,astat)==0)
as++;
if(strcmp(station,dstat)==0)
ds++;
}
fclose(f);
printf("%d arrival %d departure to the %s\n",as,ds,station);
return 0;
}

You might also like