2017-02-07 13 views
0

このプログラムは整数を取り、昇順にソートします。ここで私の問題は、出力番号がコンマで区切られていない、誰かが私にこれを助けてくれる?カンマで区切られた整数を出力する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; 
      } 

答えて

0

ただ、次のように

for (x=0;x<10;x++) 
     { 
      cout <<array[x]<<","; 
     } 
+0

cout << "asceの整数順序は次のとおりです。 (x = 0; x <10; x ++)の { cout <<配列[x]; cout << "、"; } – AmoghN

+1

私はこれらの変更を行い、それは働いた、ありがとう:) – AmoghN

+0

喜んでそれが助け! –

0

は、グループの最後を修正して、代わりに新しい行のカンマを印刷:

for (x=0;x<10;x++) 
{ 
    cout <<array[x]; 
    cout << ",";  
} 
+0

cout << "昇順の整数は次のとおりです。 (x = 0; x <10; x ++)の { cout <<配列[x]; cout << "、"; } – AmoghN

+1

私はこれらの変更を行い、それは働いた、ありがとう:) – AmoghN

0
cout << "The integers in ascending order are : "; 
     for (x=0;x<10;x++) 
     { 

      cout <<array[x]; 
      cout << ","; ---> changed this line and it prints output with commas 
    } 

はあなたに私を助けるために皆に感謝し、私はそれを感謝: )

関連する問題