Шпора по информатике / 002
Void main ( ) {
float x, step; int k, N;
N=7; step = M_PI / (N-1); // или 3.141593
for (k=0; k<N; k++)
{x = step*k;
cout<<" k=" << k <<"\t x="<<x <<"\t sin(x)="<<sin(x)<<endl; }
getch( ); }
// - - - - - - - - - - - -
Способ 2 – ООП, т.е. с классом.
#include <iostream.h>
#include <math.h>
#include <conio.h>
class tabsin { // класс
private: float step; / / поле класса
public: float x; int N ; / / поля класса
Содержание
- 10.3 Операторы управления
- 10. 4 Оператор мультиветвления switch
- 10.6 Применение функции printf для форматирования
- 11.1 Графические программы
- 11.2 Построение символьного графика
- 11.4 Построение графика в графическом режиме
- 12.1 Передача данных для построения графика в MathCad
- 12.4 Указатели
- 12.5 Описание указателей
- 12.6 Указатели для массивов и строк
- 13.3 Оператор динамического выделения памяти new
- Void main ( ) {
- Void tab( ); };
- Void main ( ) {
- 15.1 Класс объектов, элементы класса
- 15.2 Доступ к элементам класса
- 15.3 Вызов элементов класса
- 15.4 Конструкторы классa
- 15.5 Пример класса Tkplk
- 16.1 Наследование
- 16.2 Полиморфизм
- 16.3 О перегрузке функций и операций
- 17. 1 Среда программирования и библиотека vcl
- 17.2 Консольное приложение в Builder
- При выполнении лабораторных работ в дисплейном классе используется
- 17.5 Вид экрана в builder
- 17.6 Работа с проектом в системе Builder
- 18.1 Редактор кода
- 18.4 Пример запроса, ввода, вывода для Win -программы