Quando vado a compilare mi da questo errore:
terms does not evaluate to a function taking 2 arguments.
l'errore viene ripetuto in tutte le funzioni del programma.
Queste funzioni servono per verificare l'efficenza degli algoritmi di ordinamento, sono state dichiarate in un file cpp allegato e i prototipi in un file .h incluso all'inizio.
boh...
Il form è questo:
codice:
#pragma once
#include "mio.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <string.h>
namespace EfficenzaOrdinamenti {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ Start;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
protected:
protected:
protected:
protected:
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::TextBox^ simpleSort;
private: System::Windows::Forms::TextBox^ selectionSort;
private: System::Windows::Forms::TextBox^ bubbleSort;
private: System::Windows::Forms::TextBox^ insertionSort;
private: System::Windows::Forms::TextBox^ quickSort;
private: System::Windows::Forms::TextBox^ num;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Label^ label8;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->Start = (gcnew System::Windows::Forms::Button());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->simpleSort = (gcnew System::Windows::Forms::TextBox());
this->selectionSort = (gcnew System::Windows::Forms::TextBox());
this->bubbleSort = (gcnew System::Windows::Forms::TextBox());
this->insertionSort = (gcnew System::Windows::Forms::TextBox());
this->quickSort = (gcnew System::Windows::Forms::TextBox());
this->num = (gcnew System::Windows::Forms::TextBox());
this->label7 = (gcnew System::Windows::Forms::Label());
this->label8 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// Start
//
this->Start->Location = System::Drawing::Point(86, 305);
this->Start->Name = L"Start";
this->Start->Size = System::Drawing::Size(129, 63);
this->Start->TabIndex = 0;
this->Start->Text = L"Start";
this->Start->UseVisualStyleBackColor = true;
this->Start->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(47, 51);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(57, 13);
this->label1->TabIndex = 1;
this->label1->Text = L"SimpleSort";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(47, 91);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(70, 13);
this->label2->TabIndex = 2;
this->label2->Text = L"SelectionSort";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(47, 130);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(59, 13);
this->label3->TabIndex = 3;
this->label3->Text = L"BubbleSort";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(47, 168);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(66, 13);
this->label4->TabIndex = 4;
this->label4->Text = L"InsertionSort";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(47, 204);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(54, 13);
this->label5->TabIndex = 5;
this->label5->Text = L"QuickSort";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(47, 9);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(85, 13);
this->label6->TabIndex = 6;
this->label6->Text = L"Numero di prove";
//
// simpleSort
//
this->simpleSort->Location = System::Drawing::Point(138, 48);
this->simpleSort->Name = L"simpleSort";
this->simpleSort->Size = System::Drawing::Size(100, 20);
this->simpleSort->TabIndex = 7;
//
// selectionSort
//
this->selectionSort->Location = System::Drawing::Point(137, 88);
this->selectionSort->Name = L"selectionSort";
this->selectionSort->Size = System::Drawing::Size(100, 20);
this->selectionSort->TabIndex = 8;
//
// bubbleSort
//
this->bubbleSort->Location = System::Drawing::Point(137, 127);
this->bubbleSort->Name = L"bubbleSort";
this->bubbleSort->Size = System::Drawing::Size(100, 20);
this->bubbleSort->TabIndex = 9;
//
// insertionSort
//
this->insertionSort->Location = System::Drawing::Point(137, 165);
this->insertionSort->Name = L"insertionSort";
this->insertionSort->Size = System::Drawing::Size(100, 20);
this->insertionSort->TabIndex = 10;
//
// quickSort
//
this->quickSort->Location = System::Drawing::Point(137, 201);
this->quickSort->Name = L"quickSort";
this->quickSort->Size = System::Drawing::Size(99, 20);
this->quickSort->TabIndex = 11;
//
// num
//
this->num->Location = System::Drawing::Point(138, 6);
this->num->Name = L"num";
this->num->Size = System::Drawing::Size(35, 20);
this->num->TabIndex = 12;
this->num->Text = L"1";
//
// label7
//
this->label7->AutoSize = true;
this->label7->Location = System::Drawing::Point(66, 238);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(172, 13);
this->label7->TabIndex = 13;
this->label7->Text = L"Inserire numero di prove desiderato";
//
// label8
//
this->label8->AutoSize = true;
this->label8->Location = System::Drawing::Point(68, 260);
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(168, 13);
this->label8->TabIndex = 14;
this->label8->Text = L"(predefinito 1) quindi premere Start";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(290, 401);
this->Controls->Add(this->label8);
this->Controls->Add(this->label7);
this->Controls->Add(this->num);
this->Controls->Add(this->quickSort);
this->Controls->Add(this->insertionSort);
this->Controls->Add(this->bubbleSort);
this->Controls->Add(this->selectionSort);
this->Controls->Add(this->simpleSort);
this->Controls->Add(this->label6);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->Start);
this->Name = L"Form1";
this->Text = L"Verifica efficenza algoritmi";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
#define MAX 10000
float v[MAX], v2[MAX];
float t0, t1, speed;
int i, n, m;
m = MAX;
time_t tempo;
tempo = time (NULL);
srand ( tempo );
for ( i=0; i<m ; i++ )
v[i]= ((((float)rand())/RAND_MAX)*m);
n = Convert::ToInt32 ( num->Text );
if ( n>1 ){
//calcolo tempo simpleSort
for ( i=0 ; i<n ; i++ ) {
memcpy ( v2, v, m*sizeof(float) );
t0= GetTickCount();
simpleSort ( v2, m );
t1= GetTickCount();
speed += ( t1-t0 );
}
simpleSort->Text = Convert::ToString ( speed/(float)n );
//calcolo tempo selectionSort
for ( i=0 ; i<n ; i++ ) {
memcpy ( v2, v, m*sizeof(float));
t0= GetTickCount();
selectionSort ( v2, m );
t1= GetTickCount();
}
selectionSort->Text = Convert::ToString ( speed/(float)n );
for ( i=0 ; i<n ; i++ ) {
//calcolo tempo bubbleSort
memcpy ( v2, v, m*sizeof(float));
t0= GetTickCount();
bubbleSort ( v2, m );
t1= GetTickCount();
}
bubbleSort->Text = Convert::ToString ( speed/(float)n );
//calcolo tempo insertionSort
for ( i=0 ; i<n ; i++ ) {
memcpy ( v2, v, m*sizeof(float));
t0= GetTickCount();
insertionSort ( v2, m );
t1= GetTickCount();
}
insertionSort->Text = Convert::ToString ( speed/(float)n );
//calcolo tempo quickSort
for ( i=0 ; i<n ; i++ ) {
memcpy ( v2, v, m*sizeof(float));
t0= GetTickCount();
quickSort ( v2, m );
t1= GetTickCount();
}
quickSort->Text = Convert::ToString ( speed/(float)n );
}
}
};
}
Il file cpp eccolo:
codice:
#include "stdafx.h"
void swap ( float*a, float*b ) {
float help;
help= *a;
*a= *b;
*b= help;
}
//simpleSort
void simpleSort (float *v, int n ) {
int i, j;
for ( i=0 ; i<n ; i++ )
for ( j=i+1; j < n ; j++)
if ( v[i]>v[j] )
swap ( &v[i],&v[j]);
}
//selectionSort
void selectionSort( float *v, int n ) {
int i, j, p;
float min;
for ( i=0; i<n-1 ; i++ ) {
min = v[i];
p = i;
for ( j=i+1 ; j<n ; j++ )
if (v[j]<min){
min = v[j];
p = j;
}
v[p] = v[i];
v[i] = min;
}
}
//bubbleSort
void bubbleSort( float *v, int n ) {
int i, j, temp;
int test;
for ( i=n-1 ; i>0 ; i-- ) {
test = 0;
for ( j=0 ; j<i ; j++ )
if ( v[j]>v[j+1] ) {
swap ( &v[j], &v[j+1] );
test = 1;
}
if ( test==0 ) break;
}
}
//insertionSort
void insertionSort (float*v, int n) {
int i, j;
float app;
for ( i=1 ; i<n ; i++ ) {
app = v[i];
j = i-1;
while ( (j>=0) && (v[j]>app) ) {
v[j+1] = v[j];
j--;
}
v[j+1] = app;
}
}
//quickSort
void sort( float *v, int beg, int end ) {
if ( end>beg+1 ) {
int piv = v[beg], l=beg+1, r=end;
while ( l<r ) {
if ( v[l]<=piv )
l++;
else
swap( &v[l], &v[--r] );
}
swap( &v[--l], &v[beg] );
sort( v, beg, l );
sort( v, r, end );
}
}
void quickSort( float *v, int n ) {
sort ( v, 0, n-1 );
}
E questo è il .h
codice:
void swap ( float*a, float*b );
void simpleSort ( float *v, int n );
void selectionSort ( float *v, int n );
void bubbleSort ( float *v, int n );
void insertionSort ( float *v, int n );
void sort ( float *v, int beg, int end );
void quickSort ( float *v, int n );
HELPPPPPP