case 3:
printf("Exiting...\n");
break;
default:
printf("Invalid choice\n");
break;
}
} while (choice != 3);
return 0;
}
Файл, който чете:
#include
int main()
{
int a, i, flag, number;
flag=0;
i=0;
printf("Vyvedi a: ");
while (scanf("%d", &a) != EOF)
{
i++;
if (a%7 == 0)
{
flag = 1;
number = i;
}
printf(" Stojnost na i= %d, Stojnost na flag= %d\n", i, flag);
printf(" Vyvedi a za sledvashta iteracia: ");
}
if (flag)
printf("Ima kratni elementi - posledniqt e s nomer = %d\n", number);
else
printf("Njama kratni elementi.\n");
return 0;
}
Резултати, които дава (опция 1 и опция 2):
Блоксхема на програмата:
Начало
(If choice ==3) exit
Decide from options 1-3
Loop back to menu 1-3.
Край
Else: Open and read file, count operators and if-else statements, write results to file, close results file.
Read program from file and write result to file.
Else: Open and read file, count operators and if-else statements, display results to screen, close program file.
Loop back to menu 1-3.
Open program file. IF program file not found display error message.
Exiting the program.
Open program file. IF program file not found display error message.
Read program from file and print results to screen.
Displays Menu
(If choice ==3)
(If choice == 1)
(If choice==2)
(If choice ==3) exit
Сподели с приятели: |