Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
編集:これを機能させるにはどうすればよいですか。vektor[x] スロット内のすべてに k を追加したい。
char vektor[]=str.toCharArray(); int k =0, x=4; while(x>0){ vektor[x]=(char)vektor[x]+k; System.out.println(vektor[x]); x--; k++; }
k変数を宣言していませんか?ベクトル[k]は存在しません
vektor[kl] = kl + 'A';
ただし、この will 式は整数を生成します。キャストを使用する必要があります
vektor[k] = (char) (kl + 'A');
あなたはチャーストする必要があります、これを試してください:
vektor[k]=(char)(kl+'A');
最後の部分に括弧を追加するのを忘れていました。これは機能するはずです。