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

UptoLike

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

if(output==NULL) {error(2); return 0;}
fscanf(input,"%s",number);
num=StrToInt(number);
if(num%2==1) nechet(num);
if(num%4==0) chet4(num);
if(num%2==0 && num%4!=0) chet2(num);
if(num==3) schet=1;
else
if(num>3 && num<10) schet=2;
else schet=3;
switch(schet)
{
case 1: for(i=0;i<num;i++)
{
for(j=0;j<num;j++)
fprintf(output,"%i ",cub[i][j]);
fprintf(output,"\n");
}
break;
case 2: for(i=0;i<num;i++)
{
for(j=0;j<num;j++)
fprintf(output,"%.2i ",cub[i][j]);
fprintf(output,"\n");
}
break;
case 3: for(i=0;i<num;i++)
{
for(j=0;j<num;j++)
fprintf(output,"%.3i ",cub[i][j]);
fprintf(output,"\n");
}
}
free(cub);
fclose(input);
fclose(output);
printf("End of work. Press <ENTER> to exit"); getchar(); clrscr();
return 0;
}
Решение задачи 5
#include<stdio.h>
#include<alloc.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
int number,string;
int *massiv;
char temp[80];
FILE *input,*output;
void error(int swt)
{
switch(swt)
{case 1: printf("Can't find text file \"input.txt\".\n");
printf("Work of programm has finished. Press <ENTER> to halt");
getchar(); clrscr(); break;
case 2: printf("Can't create text file \"output.txt\".\n");
printf("Work of programm has finished. Press <ENTER> to halt");
getchar(); clrscr(); break;
case 3: printf("The number of registrs must be more than 0!\n");
printf("Work of programm has finished. Press <ENTER> to halt");
getchar(); clrscr(); break;