Основы программирования для автоматизированного проектирования и решения творческих задач - 64 стр.

UptoLike

Составители: 

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");
printf("End of work. Press <ENTER> to halt"); getch(); clrscr(); exit(1);
}
}
void work(void)
{
int i, j;
fscanf(input,"%i",&m); n=0; i=j=0;
do
{fscanf(input,"%i",&i); fscanf(input,"%i",&j);
if(j<i) {i=i+j; j=i-j; i=i-j;}
if(i<j) ;
{if(start==NULL) {start=malloc(sizeof(struct pokr)); uk=start;}
else {uk->next=malloc(sizeof(struct pokr)); uk=uk->next;}
uk->next=NULL; uk->a=i; uk->b=j;
if(i<=0 && j>=m) {uk->in=1; n++;}