今天編的一個C++程式

來源:互聯網
上載者:User

標籤:日常

編的程式運行一半停止工作,有沒有誰幫我看看error在哪。
原題:編一個程式,用同一個函數名對n 個資料進行從小到大排序,資料類型可以是整
型、單精確度型、雙精確度型。用重載函數實現。
我編的程式:
#include<iostream>
#include<cstring>
using namespace std;
int xu(int *p,int n)
{int i = 0,j = 0,t;
for(i = 0;i<n;i++)
for(j = 0;i<n;j++)
if(p[i]>p[j])
{t = p[i];
p[i] = p[j];
p[j] = t;
}
for(i = 0;i<n;i++)
cout<<p[i];
return 0;
}

float xu(float *p,int n)
{int i = 0,j = 0;
float t;
for(i = 0;i<n;i++)
for(j = 0;j<n;j++)
if(p[i]>p[j])
{t = p[i];
p[i] = p[j];
p[j] = t;
}
for(i = 0;i<n;i++)
cout<<p[i];
return 0;
}

int main()
{int xu(int p,int n);
float xu(float
p,int n);
int q;
cout<<"q =";
cin>>q;
int i = 0;
int p= new int[q];
for(i = 0;i<q;i++)
cin>>p[i];
float
p1= new float[q];
for(i = 0;i<q;i++)
cin>>p1[i];
xu(p,q);
xu(p1,q);
return 0;
}

今天編的一個C++程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.