該程序採用整數並按升序對它們進行排序。我的問題在這裏是不輸出數字用逗號分隔,有人可以幫我這個嗎?輸出整數以逗號分隔的C++程序
#include <iostream>
#include <cstdlib>
using namespace std;
int main() { int x;
int array [10], t;
for (x=0; x<10; x++)
{
cout << "Enter integer number: " << endl;
cin >> array[x];
}
for (x=0; x<10; x++)
{
for (int y=0; y<9; y++)
{
if(array[y]>array[y+1])
{
t=array[y];
array[y]=array[y+1];
array[y+1]=t;
}
}
}
cout << "The integers in ascending order are : ";
for (x=0;x<10;x++)
{
cout <<"\n";
cout <<array[x];
cout << "\n";
}
system ("pause");
return 0;
}
cout <<「整數順序是:「; (x = 0; x <10; x ++) cout <<「,」; } – AmoghN
我做了這些改變,它的工作,謝謝:) – AmoghN
很高興它幫助! –