Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
741 B
0
Indexable
Never
#include <iostream>
#include <cmath>
#include <fstream>
#include<vector>
using namespace std;

void func1(float* a_pt, float x) {
	float i;
	for (i = 0; i < 100; i++)
	{
		*a_pt = sin(x) * i;
		*a_pt++;
	}
}
void func2(vector<float>& a2, float x) {
	float i;
	for (i = 0; i < 100; i++)
	{
		a2.push_back(sin(x) * i);
	}
}
int main() {
	ofstream out("output.txt");
	float a[100];
	float *a_pt = a;
	float x = 0.25;
	vector<float> a2;

	func1(a_pt, x);
	func2(a2, x);
	for (int i = 0; i < 100; i++)
	{
		out <<"x = " << x << " i = " << i << " sin(x) * i = " << a[i] << endl;
	}
	out << endl;
	for (int i = 0; i < 100; i++)
	{
		out << "x = " << x << " i = " << i << " sin(x) * i = " << a[i] << endl;
	}
}