Loading...
More C++ Posts
//Leif Messinger//Finds all sets of 5 5 letter words that don't have duplicate letters in either themselves or each other.//First it reads the words in and puts them in groups of their bitmasks//After that, we recurse on each group. Before doing that, we remove the group from the set of other groups to check it against.#include <cstdio> //getchar, printf#include <cassert> //assert#include <vector>#include <set>#include <algorithm> //std::copy_if#include <iterator> //std::back_inserter#define CHECK_FOR_CRLF true#define MIN_WORDS 5#define MAX_WORDS 5#define WORD_TOO_LONG(len) (len != 5)const unsigned int charToBitmask(const char bruh){assert(bruh >= 'a' && bruh <= 'z');return (1 << (bruh - 'a'));}void printBitmask(unsigned int bitmask){char start = 'a';while(bitmask != 0){if(bitmask & 1){putchar(start);}bitmask >>= 1;++start;}}//Pointer needs to be deletedconst std::set<unsigned int>* getBitmasks(){std::set<unsigned int>* bitmasksPointer = new std::set<unsigned int>;std::set<unsigned int>& bitmasks = (*bitmasksPointer);unsigned int bitmask = 0;unsigned int wordLength = 0;bool duplicateLetters = false;for(char c = getchar(); c >= 0; c = getchar()){if(CHECK_FOR_CRLF && c == '\r'){continue;}if(c == '\n'){if(!(WORD_TOO_LONG(wordLength) || duplicateLetters)) bitmasks.insert(bitmask);bitmask = 0;wordLength = 0;duplicateLetters = false;continue;}if((bitmask & charToBitmask(c)) != 0) duplicateLetters = true;bitmask |= charToBitmask(c);++wordLength;}return bitmasksPointer;}void printBitmasks(const std::vector<unsigned int>& bitmasks){for(unsigned int bruh : bitmasks){printBitmask(bruh);putchar(','); putchar(' ');}puts("");}//Just to be clear, when I mean "word", I mean a group of words with the same letters.void recurse(std::vector<unsigned int>& oldBitmasks, std::vector<unsigned int> history, const unsigned int currentBitmask){//If there's not enough words leftif(oldBitmasks.size() + (-(history.size())) + (-MIN_WORDS) <= 0){//If there's enough wordsif(history.size() >= MIN_WORDS){//Print the listprintBitmasks(history);}return;//To make it faster, we can stop it after 5 words too}else if(history.size() >= MAX_WORDS){//Print the listprintBitmasks(history);return;}//Thin out the array with only stuff that matches the currentBitmask.std::vector<unsigned int> newBitmasks;std::copy_if(oldBitmasks.begin(), oldBitmasks.end(), std::back_inserter(newBitmasks), [¤tBitmask](unsigned int bruh){return (bruh & currentBitmask) == 0;});while(newBitmasks.size() > 0){//I know this modifies 'oldBitmasks' too. It's intentional.//This makes it so that the word is never involved in any of the child serches or any of the later searches in this while loop.const unsigned int word = newBitmasks.back(); newBitmasks.pop_back();std::vector<unsigned int> newHistory = history;newHistory.push_back(word);recurse(newBitmasks, newHistory, currentBitmask | word);}}int main(){const std::set<unsigned int>* bitmasksSet = getBitmasks();std::vector<unsigned int> bitmasks(bitmasksSet->begin(), bitmasksSet->end());delete bitmasksSet;recurse(bitmasks, std::vector<unsigned int>(), 0);return 0;}
#include <iostream>int main(){const char* const hello = "Hello, world!";const char* bruh = hello;char* const yeet = hello;std::cout << bruh << std::endl;std::cout << yeet << std::endl;return 0;}/*Place your bets!Will the program:a.) Print "Hello, world!" twice?b.) Compile error on line 5 (bruh initialize line) because the pointer gets implicit cast to non-const?c.) Compile error on line 7 (yeet initialize line) because the char gets implicit cast to non-const?d.) Both b and c?e.) Compile error line 11 (print yeet) because the pointer is constant and can't be incrementedf.) Print "Hello, world!" then print the pointer address in hexadecimalg.) Both b and e?h.) Both c and e?i.) B, c, and e?*/// The answer is in this base 64 string:// T25seSBjLikKVGhlIGNvbXBpbGVyIGRvZXNuJ3QgYXBwcmVjaWF0ZSB5b3UgbWFraW5nIHRoZSBjaGFyYWN0ZXJzIHRoZSBwb2ludGVyIHJlZmVycyB0byBub24tY29uc3QsIGJ1dCBpdCdzIGZpbmUgd2l0aCB5b3UgY29weWluZyBhIGNvbnN0YW50IHZhbHVlLCBpLmUuIHRoZSBwb2ludGVyLCB0byBhIG5vbi1jb25zdGFudCB2YXJpYWJsZS4KSWYgeW91IHJlcGxhY2UgdGhhdCBsaW5lIHdpdGggY2hhciogY29uc3QgeWVldCA9IGNvbnN0X2Nhc3Q8Y2hhciogY29uc3Q+KGhlbGxvKTsgSXQnbGwgcHJpbnQgIkhlbGxvLCB3b3JsZCEiIHR3aWNlLCB3aGljaCBpcyB2ZXJ5IHN0cmFuZ2UgY29uc2lkZXJpbmcgdGhhdCB5ZWV0IGlzIGEgY29uc3QgcG9pbnRlciwgc28geW91J2QgdGhpbmsgaXQgd291bGQgcHJpbnQgYXMgYSBoZXhhZGVjaW1hbCBiZWNhdXNlIGlmIHlvdSB0cnkgdG8gKCsreWVldCkgd2hpbGUgbG9vcGluZyB0aHJvdWdoIHRoZSBzdHJpbmcsIHlvdSdkIGdldCBhbiBlcnJvciwgYmVjYXVzZSBpdCdzIGNvbnN0IGFuZCBjYW4ndCBiZSBjaGFuZ2VkLgpJbnN0ZWFkIG9mIHVzaW5nIGEgdGVtcGxhdGUgZnVuY3Rpb24gZm9yIG9zdHJlYW06Om9wZXJhdG9yPDwsIHRoZXkgbWFrZSBpdCBhIGZ1bmN0aW9uIHRoYXQgdGFrZXMgdHlwZSBjb25zdCBjaGFyKiwgYW5kIEMrKyBoYXMgbm8gcHJvYmxlbXMgcHJvbW90aW5nIGEgdmFyaWFibGUgdG8gY29uc3RhbnQgd2hlbiBpbXBsaWNpdCBjYXN0aW5nLCBhbmQgaXQgaGFzIG5vIHByb2JsZW1zIGltcGxpY2l0IGNhc3RpbmcgdGhlIGNvbnN0IHBvaW50ZXIgdG8gYSBub3JtYWwgcG9pbnRlciBiZWNhdXNlIGl0J3MgbWFraW5nIGEgY29weS4gVGhlIHBvaW50ZXIgZ2V0cyBjb3BpZWQgYmVjYXVzZSB0aGUgcG9pbnRlciBpcyBwYXNzZWQgYnkgdmFsdWUsIG5vdCByZWZlcmVuY2Uu
#include <iostream>using namespace std;int main(){int arr[] = {5, 1, 4, 20, 10, 2, 13, 11, 6, 21};int greed[] = {0, 0, 0, 0};int k = 0;int i;int set_index;while (k < 4){i = 0;while (i < 10){if (arr[i] > greed[k]){greed[k] = arr[i];set_index = i;}i++;}arr[set_index] = 0;k++;}cout << greed[0] << " " << greed[1] << " " << greed[2] << " " << greed[3] << endl;}
#include <string>#include <iostream>#include "PlaylistNode.h"using namespace std;PlaylistNode::PlaylistNode() {uniqueID = "none";songName = "none";artistName = "none";songLength = 0;nextNodePtr = 0;}PlaylistNode::PlaylistNode(string uniqueID_, string songName_, string artistName_, int songLength_) {uniqueID = uniqueID_;songName = songName_;artistName = artistName_;songLength = songLength_;nextNodePtr = 0;}void PlaylistNode::InsertAfter(PlaylistNode* ptr) {this->SetNext(ptr->GetNext());ptr->SetNext(this);}void PlaylistNode::SetNext(PlaylistNode* ptr) {nextNodePtr = ptr;}string PlaylistNode::GetID() {return uniqueID;}string PlaylistNode::GetSongName() {return songName;}string PlaylistNode::GetArtistName() {return artistName;}int PlaylistNode::GetSongLength() {return songLength;}PlaylistNode* PlaylistNode::GetNext() {return nextNodePtr;}void PlaylistNode::PrintPlaylistNode() {cout << "Unique ID: " << uniqueID << endl;cout << "Song Name: " << songName << endl;cout << "Artist Name: " << artistName << endl;cout << "Song Length (in seconds): " << songLength << endl;}Playlist::Playlist() {head = tail = 0;}void Playlist::AddSong(string id, string songname, string artistname, int length) {PlaylistNode* n = new PlaylistNode(id, songname, artistname, length);if (head == 0) {head = tail = n;}else {n->InsertAfter(tail);tail = n;}}bool Playlist::RemoveSong(string id) {if (head == NULL) {cout << "Playlist is empty" << endl;return false;}PlaylistNode* curr = head;PlaylistNode* prev = NULL;while (curr != NULL) {if (curr->GetID() == id) {break;}prev = curr;curr = curr->GetNext();}if (curr == NULL) {cout << "\"" << curr->GetSongName() << "\" is not found" << endl;return false;}else {if (prev != NULL) {prev ->SetNext(curr->GetNext());}else {head = curr->GetNext();}if (tail == curr) {tail = prev;}cout << "\"" << curr->GetSongName() << "\" removed." << endl;delete curr;return true;}}bool Playlist::ChangePosition(int oldPos, int newPos) {if (head == NULL) {cout << "Playlist is empty" << endl;return false;}PlaylistNode* prev = NULL;PlaylistNode* curr = head;int pos;if (head == NULL || head == tail) {return false;}for (pos = 1; curr != NULL && pos < oldPos; pos++) {prev = curr;curr = curr->GetNext();}if (curr != NULL) {string currentSong = curr->GetSongName();if (prev == NULL) {head = curr->GetNext();}else {prev->SetNext(curr->GetNext());}if (curr == tail) {tail = prev;}PlaylistNode* curr1 = curr;prev = NULL;curr = head;for (pos = 1; curr != NULL && pos < newPos; pos++) {prev = curr;curr = curr->GetNext();}if (prev == NULL) {curr1->SetNext(head);head = curr1;}else {curr1->InsertAfter(prev);}if (curr == NULL) {tail = curr1;}cout << "\"" << currentSong << "\" moved to position " << newPos << endl;return true;}else {cout << "Song's current position is invalid" << endl;return false;}}void Playlist::SongsByArtist(string artist) {if (head == NULL) {cout << "Playlist is empty" << endl;}else {PlaylistNode* curr = head;int i = 1;while (curr != NULL) {if (curr->GetArtistName() == artist) {cout << endl << i << "." << endl;curr->PrintPlaylistNode();}curr = curr->GetNext();i++;}}}int Playlist::TotalTime() {int total = 0;PlaylistNode* curr = head;while (curr != NULL) {total += curr->GetSongLength();curr = curr->GetNext();}return total;}void Playlist::PrintList() {if (head == NULL) {cout << "Playlist is empty" << endl;}else {PlaylistNode* curr = head;int i = 1;while (curr != NULL) {cout << endl << i++ << "." << endl;curr->PrintPlaylistNode();curr = curr->GetNext();}}}
#include <iostream>#include <vector>#include <utility>#include <algorithm>#include <chrono>using namespace std;#include <stdio.h>#include <Windows.h>int nScreenWidth = 120; // Console Screen Size X (columns)int nScreenHeight = 40; // Console Screen Size Y (rows)int nMapWidth = 16; // World Dimensionsint nMapHeight = 16;float fPlayerX = 14.7f; // Player Start Positionfloat fPlayerY = 5.09f;float fPlayerA = 0.0f; // Player Start Rotationfloat fFOV = 3.14159f / 4.0f; // Field of Viewfloat fDepth = 16.0f; // Maximum rendering distancefloat fSpeed = 5.0f; // Walking Speedint main(){// Create Screen Bufferwchar_t *screen = new wchar_t[nScreenWidth*nScreenHeight];HANDLE hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);SetConsoleActiveScreenBuffer(hConsole);DWORD dwBytesWritten = 0;// Create Map of world space # = wall block, . = spacewstring map;map += L"#########.......";map += L"#...............";map += L"#.......########";map += L"#..............#";map += L"#......##......#";map += L"#......##......#";map += L"#..............#";map += L"###............#";map += L"##.............#";map += L"#......####..###";map += L"#......#.......#";map += L"#......#.......#";map += L"#..............#";map += L"#......#########";map += L"#..............#";map += L"################";auto tp1 = chrono::system_clock::now();auto tp2 = chrono::system_clock::now();while (1){// We'll need time differential per frame to calculate modification// to movement speeds, to ensure consistant movement, as ray-tracing// is non-deterministictp2 = chrono::system_clock::now();chrono::duration<float> elapsedTime = tp2 - tp1;tp1 = tp2;float fElapsedTime = elapsedTime.count();// Handle CCW Rotationif (GetAsyncKeyState((unsigned short)'A') & 0x8000)fPlayerA -= (fSpeed * 0.75f) * fElapsedTime;// Handle CW Rotationif (GetAsyncKeyState((unsigned short)'D') & 0x8000)fPlayerA += (fSpeed * 0.75f) * fElapsedTime;// Handle Forwards movement & collisionif (GetAsyncKeyState((unsigned short)'W') & 0x8000){fPlayerX += sinf(fPlayerA) * fSpeed * fElapsedTime;;fPlayerY += cosf(fPlayerA) * fSpeed * fElapsedTime;;if (map.c_str()[(int)fPlayerX * nMapWidth + (int)fPlayerY] == '#'){fPlayerX -= sinf(fPlayerA) * fSpeed * fElapsedTime;;fPlayerY -= cosf(fPlayerA) * fSpeed * fElapsedTime;;}}// Handle backwards movement & collisionif (GetAsyncKeyState((unsigned short)'S') & 0x8000){fPlayerX -= sinf(fPlayerA) * fSpeed * fElapsedTime;;fPlayerY -= cosf(fPlayerA) * fSpeed * fElapsedTime;;if (map.c_str()[(int)fPlayerX * nMapWidth + (int)fPlayerY] == '#'){fPlayerX += sinf(fPlayerA) * fSpeed * fElapsedTime;;fPlayerY += cosf(fPlayerA) * fSpeed * fElapsedTime;;}}for (int x = 0; x < nScreenWidth; x++){// For each column, calculate the projected ray angle into world spacefloat fRayAngle = (fPlayerA - fFOV/2.0f) + ((float)x / (float)nScreenWidth) * fFOV;// Find distance to wallfloat fStepSize = 0.1f; // Increment size for ray casting, decrease to increasefloat fDistanceToWall = 0.0f; // resolutionbool bHitWall = false; // Set when ray hits wall blockbool bBoundary = false; // Set when ray hits boundary between two wall blocksfloat fEyeX = sinf(fRayAngle); // Unit vector for ray in player spacefloat fEyeY = cosf(fRayAngle);// Incrementally cast ray from player, along ray angle, testing for// intersection with a blockwhile (!bHitWall && fDistanceToWall < fDepth){fDistanceToWall += fStepSize;int nTestX = (int)(fPlayerX + fEyeX * fDistanceToWall);int nTestY = (int)(fPlayerY + fEyeY * fDistanceToWall);// Test if ray is out of boundsif (nTestX < 0 || nTestX >= nMapWidth || nTestY < 0 || nTestY >= nMapHeight){bHitWall = true; // Just set distance to maximum depthfDistanceToWall = fDepth;}else{// Ray is inbounds so test to see if the ray cell is a wall blockif (map.c_str()[nTestX * nMapWidth + nTestY] == '#'){// Ray has hit wallbHitWall = true;// To highlight tile boundaries, cast a ray from each corner// of the tile, to the player. The more coincident this ray// is to the rendering ray, the closer we are to a tile// boundary, which we'll shade to add detail to the wallsvector<pair<float, float>> p;// Test each corner of hit tile, storing the distance from// the player, and the calculated dot product of the two raysfor (int tx = 0; tx < 2; tx++)for (int ty = 0; ty < 2; ty++){// Angle of corner to eyefloat vy = (float)nTestY + ty - fPlayerY;float vx = (float)nTestX + tx - fPlayerX;float d = sqrt(vx*vx + vy*vy);float dot = (fEyeX * vx / d) + (fEyeY * vy / d);p.push_back(make_pair(d, dot));}// Sort Pairs from closest to farthestsort(p.begin(), p.end(), [](const pair<float, float> &left, const pair<float, float> &right) {return left.first < right.first; });// First two/three are closest (we will never see all four)float fBound = 0.01;if (acos(p.at(0).second) < fBound) bBoundary = true;if (acos(p.at(1).second) < fBound) bBoundary = true;if (acos(p.at(2).second) < fBound) bBoundary = true;}}}// Calculate distance to ceiling and floorint nCeiling = (float)(nScreenHeight/2.0) - nScreenHeight / ((float)fDistanceToWall);int nFloor = nScreenHeight - nCeiling;// Shader walls based on distanceshort nShade = ' ';if (fDistanceToWall <= fDepth / 4.0f) nShade = 0x2588; // Very closeelse if (fDistanceToWall < fDepth / 3.0f) nShade = 0x2593;else if (fDistanceToWall < fDepth / 2.0f) nShade = 0x2592;else if (fDistanceToWall < fDepth) nShade = 0x2591;else nShade = ' '; // Too far awayif (bBoundary) nShade = ' '; // Black it outfor (int y = 0; y < nScreenHeight; y++){// Each Rowif(y <= nCeiling)screen[y*nScreenWidth + x] = ' ';else if(y > nCeiling && y <= nFloor)screen[y*nScreenWidth + x] = nShade;else // Floor{// Shade floor based on distancefloat b = 1.0f - (((float)y -nScreenHeight/2.0f) / ((float)nScreenHeight / 2.0f));if (b < 0.25) nShade = '#';else if (b < 0.5) nShade = 'x';else if (b < 0.75) nShade = '.';else if (b < 0.9) nShade = '-';else nShade = ' ';screen[y*nScreenWidth + x] = nShade;}}}// Display Statsswprintf_s(screen, 40, L"X=%3.2f, Y=%3.2f, A=%3.2f FPS=%3.2f ", fPlayerX, fPlayerY, fPlayerA, 1.0f/fElapsedTime);// Display Mapfor (int nx = 0; nx < nMapWidth; nx++)for (int ny = 0; ny < nMapWidth; ny++){screen[(ny+1)*nScreenWidth + nx] = map[ny * nMapWidth + nx];}screen[((int)fPlayerX+1) * nScreenWidth + (int)fPlayerY] = 'P';// Display Framescreen[nScreenWidth * nScreenHeight - 1] = '\0';WriteConsoleOutputCharacter(hConsole, screen, nScreenWidth * nScreenHeight, { 0,0 }, &dwBytesWritten);}return 0;}
//From https://create.arduino.cc/projecthub/abhilashpatel121/easyfft-fast-fourier-transform-fft-for-arduino-9d2677#include <cmath>#include <iostream>const unsigned char sine_data[] = { //Quarter a sine wave0,4, 9, 13, 18, 22, 27, 31, 35, 40, 44,49, 53, 57, 62, 66, 70, 75, 79, 83, 87,91, 96, 100, 104, 108, 112, 116, 120, 124, 127,131, 135, 139, 143, 146, 150, 153, 157, 160, 164,167, 171, 174, 177, 180, 183, 186, 189, 192, 195, //Paste this at top of program198, 201, 204, 206, 209, 211, 214, 216, 219, 221,223, 225, 227, 229, 231, 233, 235, 236, 238, 240,241, 243, 244, 245, 246, 247, 248, 249, 250, 251,252, 253, 253, 254, 254, 254, 255, 255, 255, 255};float sine(int i){ //Inefficient sineint j=i;float out;while(j < 0) j = j + 360;while(j > 360) j = j - 360;if(j > -1 && j < 91) out = sine_data[j];else if(j > 90 && j < 181) out = sine_data[180 - j];else if(j > 180 && j < 271) out = -sine_data[j - 180];else if(j > 270 && j < 361) out = -sine_data[360 - j];return (out / 255);}float cosine(int i){ //Inefficient cosineint j = i;float out;while(j < 0) j = j + 360;while(j > 360) j = j - 360;if(j > -1 && j < 91) out = sine_data[90 - j];else if(j > 90 && j < 181) out = -sine_data[j - 90];else if(j > 180 && j < 271) out = -sine_data[270 - j];else if(j > 270 && j < 361) out = sine_data[j - 270];return (out / 255);}//Example data://-----------------------------FFT Function----------------------------------------------//float* FFT(int in[],unsigned int N,float Frequency){ //Result is highest frequencies in order of loudness. Needs to be deleted./*Code to perform FFT on arduino,setup:paste sine_data [91] at top of program [global variable], paste FFT function at end of programTerm:1. in[] : Data array,2. N : Number of sample (recommended sample size 2,4,8,16,32,64,128...)3. Frequency: sampling frequency required as input (Hz)If sample size is not in power of 2 it will be clipped to lower side of number.i.e, for 150 number of samples, code will consider first 128 sample, remaining sample will be omitted.For Arduino nano, FFT of more than 128 sample not possible due to mamory limitation (64 recomended)For higher Number of sample may arise Mamory related issue,Code by ABHILASHContact: [email protected]Documentation:https://www.instructables.com/member/abhilash_patel/instructables/2/3/2021: change data type of N from float to int for >=256 samples*/unsigned int sampleRates[13]={1,2,4,8,16,32,64,128,256,512,1024,2048};int a = N;int o;for(int i=0;i<12;i++){ //Snapping N to a sample rate in sampleRatesif(sampleRates[i]<=a){o = i;}}int in_ps[sampleRates[o]] = {}; //input for sequencingfloat out_r[sampleRates[o]] = {}; //real part of transformfloat out_im[sampleRates[o]] = {}; //imaginory part of transformint x = 0;int c1;int f;for(int b=0;b<o;b++){ // bit reversalc1 = sampleRates[b];f = sampleRates[o] / (c1 + c1);for(int j = 0;j < c1;j++){x = x + 1;in_ps[x]=in_ps[j]+f;}}for(int i=0;i<sampleRates[o];i++){ // update input array as per bit reverse orderif(in_ps[i]<a){out_r[i]=in[in_ps[i]];}if(in_ps[i]>a){out_r[i]=in[in_ps[i]-a];}}int i10,i11,n1;float e,c,s,tr,ti;for(int i=0;i<o;i++){ //ffti10 = sampleRates[i]; // overall values of sine/cosine :i11 = sampleRates[o] / sampleRates[i+1]; // loop with similar sine cosine:e = 360 / sampleRates[i+1];e = 0 - e;n1 = 0;for(int j=0;j<i10;j++){c=cosine(e*j);s=sine(e*j);n1=j;for(int k=0;k<i11;k++){tr = c*out_r[i10 + n1]-s*out_im[i10 + n1];ti = s*out_r[i10 + n1]+c*out_im[i10 + n1];out_r[n1 + i10] = out_r[n1]-tr;out_r[n1] = out_r[n1]+tr;out_im[n1 + i10] = out_im[n1]-ti;out_im[n1] = out_im[n1]+ti;n1 = n1+i10+i10;}}}/*for(int i=0;i<sampleRates[o];i++){std::cout << (out_r[i]);std::cout << ("\t"); // un comment to print RAW o/pstd::cout << (out_im[i]); std::cout << ("i");std::cout << std::endl;}*///---> here onward out_r contains amplitude and our_in conntains frequency (Hz)for(int i=0;i<sampleRates[o-1];i++){ // getting amplitude from compex numberout_r[i] = sqrt(out_r[i]*out_r[i]+out_im[i]*out_im[i]); // to increase the speed delete sqrtout_im[i] = i * Frequency / N;std::cout << (out_im[i]); std::cout << ("Hz");std::cout << ("\t"); // un comment to print freuency binstd::cout << (out_r[i]);std::cout << std::endl;}x = 0; // peak detectionfor(int i=1;i<sampleRates[o-1]-1;i++){if(out_r[i]>out_r[i-1] && out_r[i]>out_r[i+1]){in_ps[x] = i; //in_ps array used for storage of peak numberx = x + 1;}}s = 0;c = 0;for(int i=0;i<x;i++){ // re arraange as per magnitudefor(int j=c;j<x;j++){if(out_r[in_ps[i]]<out_r[in_ps[j]]){s=in_ps[i];in_ps[i]=in_ps[j];in_ps[j]=s;}}c=c+1;}float* f_peaks = new float[sampleRates[o]];for(int i=0;i<5;i++){ // updating f_peak array (global variable)with descending orderf_peaks[i]=out_im[in_ps[i]];}return f_peaks;}//------------------------------------------------------------------------------------////main.cppint data[64]={14, 30, 35, 34, 34, 40, 46, 45, 30, 4, -26, -48, -55, -49, -37,-28, -24, -22, -13, 6, 32, 55, 65, 57, 38, 17, 1, -6, -11, -19, -34,-51, -61, -56, -35, -7, 18, 32, 35, 34, 35, 41, 46, 43, 26, -2, -31, -50,-55, -47, -35, -27, -24, -21, -10, 11, 37, 58, 64, 55, 34, 13, -1, -7};int main(){const unsigned int SAMPLE_RATE = 48*1000; //48khzauto result = FFT(data,64,SAMPLE_RATE);std::cout << result[0] << " " << result[1] << " " << result[2] << " " << result[3] << std::endl;delete[] result;return 0;}