#include<iostream>
using namespace std;
struct Node {
double a;
Node* next;
Node(int x) :a(x), next(NULL) {}
};
bool isInOrder(Node* first) {
Node* p = first;
if (p == NULL) return false;
while (p != NULL) {
if (p->a > p->next->a) return false;
p = p->next;
}
return true;
}
int main() {
int n;
double m;
cout << "please input the number of data:";
cin >> n;
cout << "please input the data:";
Node* first, * p,* f;
f = new Node(0);
first = f;
for (int i = 0; i < n; i++) {
cin >> m;
p = new Node(m);
f->next = p;
f = p;
}
first = first->next;
if (isInOrder(first) == true) cout << "This listnode is in right order./n";
else cout << "This listnode is not in right order./n";
}
uj5u.com熱心網友回復:
幫忙看看,這個哪里出問題了,不是升序的就可以正常輸出,升序的就不行了,提示是if (p->a > p->next->a) return false;這句0x00D6266B 處(位于 Project1.exe 中)引發的例外: 0xC0000005: 讀取位置 0x00000000 時發生訪問沖突。真不知道怎么搞了,在網上也查了不少解決方法,都不好使啊轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/179362.html
標籤:C++ 語言
上一篇:聊聊面試培訓機構學員的感受
下一篇:重生后被超可愛女朋友倒追 第二章
