こんにちは私は1 + 2 + 3 + 2 + 2 + 1と言うことができるように合計を取ると1 + 1として合計を並べ替える必要があるプログラムを作ろうとしている+ + 2 2 + 2 + 3私の空白の出力を与えるC++での並べ替え
これはコード
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main() {
string s;
char w[100];
char x[100];
cin>>s;
//moving string s to array w to remove the '+' charachter for sorting
for (int i=0; i>s.size() ;i++){
if (s.at(i) = '+')continue;
else s.at(i) == w[i];
}
//sorting array w
sort(w,w+100);
//moving array w to array x and re-adding the '+' after sorting
for (int y=0; y > s.size();y++){
w[y]==x[y];
x[y+1]=='+';
}
cout<<x;
return 0;
}
ですが、私はそれを実行したとき、それは私に空白の出力 を与えるこれは、C++プログラムで私の最初の時間ですまだまだ初心者です。
tあらかじめ助けを借りてハンクス!
おそらく '他s.at(I)== [i]のwは、[i]は' [I] = sでwは 'でなければなりません; '。 – lisyarus
ここで 'for(int i = 0; i> s; size); {' for(int i = 0; i s.size(); y ++){'と同じです。 –
DimChtz
また、if(s.at(i)= '+') 'おそらく:if(s.at(i)== '+')'であるべきです。 – DimChtz