菜鸟,,,,delete的问题..
程序代码:
#include<iostream> using namespace std; void Longest(int * a ) { int sum = 0 , best_i , best_j; for(int i = 0 ; a[i] != -1 ; ++i) { int temp = 1 ; for(int j = ( i + 1 ) ; ; ++j) { if(a[j] == -1 ) { if(temp > sum) { sum = temp ; best_i = i ; best_j = j - 1 ; } break; } else { if(a[j] >= a[j - 1]) ++temp ; else { if(temp > sum) { sum = temp ; best_i = i ; best_j = j - 1 ; } break; } } } } cout<<"该数组中最长的单调递增的子序列的长度是:" <<sum<<endl <<"范围是"<<best_i + 1<<"~"<<best_j + 1<<endl; return ; } int main() { int * b = new int ; cout<<"请输入一组整数,-1 表示数组结束"<<endl; for(int i = 0 ; ; ++i ) { cin>>b[i]; if(b[i] == -1) break; } Longest( b ) ; delete b ; return 0 ; }delete错误. 个人觉得没有错啊!!!!求助