小编Jim*_*NES的帖子

C ++,cin,直到使用while循环在线不再输入

我的C ++程序有问题。我重新格式化并显示用户输入到控制台中的单词。如果用户输入:嗨,我是鲍勃。用户将鲍勃输入控制台后,将按Enter。我将重新格式化并重新打印为新格式。问题是在输入该控制台行上的所有单词之前,我不想显示一条消息以进行更多输入。我当前的循环要么在每个单词之后显示输入请求,要么根本不显示输入请求。这取决于我是否包含提示。我需要进行while循环处理每个单词并输出它,并在最后一个单词之后停止。布尔参数是什么?我包括我的代码以供参考。

int _tmain(int argc, _TCHAR* argv[])
{

    int b;
    string input;
    string output ;
    int check = 1;

    while (check){
        cout << "Enter in one or more words to be output in ROT13: " << endl;
        cin >> input;
        while(my issue is here){

            const char *word = input.c_str();

            for (int i = 0; i < input.length(); i++){

                b = (int)word[i];
                if (b > 96){
                    if (b >= 110){
                        b = b - 13;
                    }
                    else {
                        b = b …
Run Code Online (Sandbox Code Playgroud)

c++ console input cin

0
推荐指数
2
解决办法
1万
查看次数

项目程序错误,我根本想不通

编译器一直说我的if else语句有一个错误,我无法弄清楚原因.

import java.util.Scanner;

public class PackingOrganizer{
    public static void main(String[] args){

        int cartons = 4, boxes = 5;

        Scanner input = new Scanner(System.in);
        System.out.print("Enter number of items : (All partial items are to be rounded up. ex. 6.5 items is rounded to 7 items)");
        double itemcount = input.nextDouble();

        if (itemcount != (int) itemcount);
            System.out.println("Invalid input round all partial numbers up");
        else if (itemcount % cartons = 0){
              int containerAmount =( itemcount \ cartons );
              System.out.println("Cartons can be used. The" …
Run Code Online (Sandbox Code Playgroud)

java debugging

-2
推荐指数
1
解决办法
62
查看次数

标签 统计

c++ ×1

cin ×1

console ×1

debugging ×1

input ×1

java ×1