ВУЗ:
Составители:
Рубрика:
#define num 7
int summa=0;
int mas[10][4]={ {0,5,-1,-1},
{1,6,8,-1},
{2,7,9,-1},
{3,4,8,-1},
{4,3,9,-1},
{5,-1,-1,-1},
{6,1,7,-1},
{7,2,6,-1},
{8,1,3,-1},
{9,0,2,4}
};
void schet(int a,int b)
{
int i;
for(i=1;i<4;i++)
if(mas[a][i]>=0)
if(b==num-1) summa++;
else schet(mas[a][i],b+1);
}
int main()
{
int i, number;
FILE *input, *output;
input=fopen("input.txt","rt");
fscanf(input,"%i",&number); fclose(input);
if(number>=10 || number<0)
{printf("Error::Number in file must be in [0..9]!!!\n");
printf("Press <ENTER> to halt programm");
getch(); clrscr(); exit(0);
}
printf("You entered: %i\nProcess working...\n..................\n",number);
output=fopen("output.txt","wt");
schet(number,1); printf("summa=%i\n",summa);
fprintf(output,"%i",summa); fclose(output);
printf("You'll find this answer in file 'output.txt'\n");
printf("End of work. Press <ENTER> to escape"); getch(); clrscr();
return 0;
}
Решение задачи 7
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct pokr
{int a,b,in;
struct pokr *next;
};
struct pokr *start,*uk;
int **mas,m,n;
FILE *input,*output;
void init(void)
{
input=fopen("input.txt","rt");
output=fopen("output.txt","wt");
if(input==NULL || output==NULL)
{printf("Error on open file 'input.txt' or on create file 'output.txt'!\n");
Страницы
- « первая
- ‹ предыдущая
- …
- 48
- 49
- 50
- 51
- 52
- …
- следующая ›
- последняя »