我的代码有什么不对? [英] What's Wrong With My Code?

查看:58
本文介绍了我的代码有什么不对?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我我的代码有什么问题。用户输入他的名字后程序崩溃了!它只是一个有趣的程序,但我想知道它有什么问题!

  #include  < span class =code-preprocessor> <  < stdio.h  > > 
#include < < conio.h > >
int main()
{
char 名称;
int answer1;
int answer2;
int answer3;
printf( 你叫什么名字?\ n);
scanf( %s,name);
printf( \ n哦哇,多么美妙的名字!\ n你好%s,什么可以我为你做的??? \ n,名字);
printf( \ n你想让我为你做点什么??? [是= 1或者NO = 2] \\\
);
scanf( %d,& answer1);
if (answer1 == 1
{

printf( \ n你想吃点东西还是想喝点什么?\ n n [EAT = 1或DRINK = 2] \ n);
scanf( %d,& answer2);
if (answer2 == 2
{

printf( 我可以为你做一杯咖啡或一杯茶!\ n你更喜欢什么? [coffee = 1或tea = 2]);
scanf( %d,& answer3);
if (answer3 == 1
{
printf( \ n以下是食谱:\ n);
printf( 正确的设备\ nCarguilo喜欢手动滴头带来的干净,健康的味道,因为它过滤掉了油和沉淀物。而且她并不孤单。基本上,倒入已成为美食咖啡店的最新产品。锥形滴头工作正常,但Carguilo更喜欢Kalita Wave的扁平底座(如右图所示,38美元;过滤器,100美元13美元:shop.wreckingball coffee.com)。地面均匀,所以水平均饱和, Carguilo说。如果您不喜欢自来水的味道,请使用过滤或装瓶。\ n \ nnFresh Grounds \ nGrind咖啡豆在半小时内酿造。毛刺研磨机是理想的但价格昂贵(50美元或更多)。它可以产生均匀的地面并防止咖啡变得太软或太苦。对于手动滴头,中等大小(simila) r到原糖颗粒)是最好的。 (了解如何选择最好的美味咖啡豆。)\ nMagic Ratio \ n要冲泡16盎司咖啡(两个大杯),使用5汤匙(或28克)咖啡和16盎司水。\\ nMaster the倒酒总时间:3到5分钟。\\ nn1。当您的水壶加热时,将一个带有纸质过滤器的滴头放在杯子或玻璃水瓶上。用热水冲洗过滤器以除去纸屑并预热锥体。\ n2。将研磨咖啡放入潮湿的过滤器中。\\ nn3。水沸腾后,等待10秒钟使其稳定下来。慢慢倒入足够的热水(以圆周运动)使所有地面饱和。\ n4。暂停30秒让咖啡绽放。 它会冒泡并软化。\ n5。再次倒水,将水位提高到地面以上一英寸。等一会儿,直到水流过滴头。重复这个脉冲浇注, 的过程,这有助于防止溢出,直到你有你想要的酿造量coffee \ n。);
printf( \ n \\\
HAHAHAHAHAHHAHA。 ......这是食谱......自己动手吧.DAMN ......你太懒了,你想要一台电脑给你喝咖啡哈哈哈哈!
);

}
if (answer3 == 2
{
printf( 煮沸水。每想要制作一个杯子,取3/4杯。水量很重要根据杯子的数量加入茶粉。你可以每杯加一茶匙。如果你想要茶更浓,那么加入更多的粉末。如果你想要保持清淡,减少茶粉的含量。现在根据你的味蕾添加糖。\\ n \\ n将混合物煮沸。当你在混合物中看到微红色调时停止。进一步煮沸会给它带来苦涩的味道。解开并倒入杯子里。给牛奶加温牛奶。对于没有牛奶的茶,加入一些生姜滴或酸橙,根据你的喜好,你很懒,你想要一台电脑为你做一杯茶...哈哈哈...... 。这是什么食物让你自己哈哈哈哈);
}
else
printf( );

}
if (answer2 == 1

{
printf( \ nOH上帝!\ n \\ n \\ n \\ n \\ n \\ n \\ n预订我变得如此肥胖......你仍然不要因为要我为你做点东西而感到羞耻。不要加入一个健身房!);
}
else
printf( );


}
if (answer1 == 2

{
printf( 哦%s,如果你什么都不想要的话吃...然后我毫无用处......因为我只擅长为我的主人做点什么。如果你想让我为你做任何事情,那就不用了。\ n只是,再次运行程序!谢谢%s ... \ nHAVE好日子,姓名,姓名);
}
else
printf( );
}



感谢您的帮助!祝你今天愉快! :)

解决方案

38;过滤器,


13 for 100:shop.wreckingball coffee.com)。 地面均匀,所以水平均饱和, Carguilo说。如果你不喜欢自来水的味道,可以在半小时的酿造过程中使用过滤或瓶装。\\ n \ nnFresh Grounds \ nGrind豆。毛刺研磨机是理想的但价格昂贵(


50或更多)。它可以产生均匀的粉末,防止咖啡过于微弱或过于苦涩。对于手动滴头,中等大小(类似于原糖颗粒)是最好的。 (了解如何选择最好的美味咖啡豆。)\ nMagic Ratio \ n要冲泡16盎司咖啡(两个大杯),使用5汤匙(或28克)咖啡和16盎司水。\\ nMaster the倒酒总时间:3到5分钟。\\ nn1。当您的水壶加热时,将一个带有纸质过滤器的滴头放在杯子或玻璃水瓶上。用热水冲洗过滤器以除去纸屑并预热锥体。\ n2。将研磨咖啡放入潮湿的过滤器中。\\ nn3。水沸腾后,等待10秒钟使其稳定下来。慢慢倒入足够的热水(以圆周运动)使所有地面饱和。\ n4。暂停30秒让咖啡绽放。 它会冒泡并软化。\ n5。再次倒水,将水位提高到地面以上一英寸。等一会儿,直到水流过滴头。重复这个脉冲浇注, 的过程,这有助于防止溢出,直到你有你想要的酿造量coffee \ n。);
printf( \ n \\\
HAHAHAHAHAHHAHA。 ......这是食谱......自己动手吧.DAMN ......你太懒了,你想要一台电脑给你喝咖啡哈哈哈哈!
);

}
if (answer3 == 2
{
printf( 煮沸水。每想要制作一个杯子,取3/4杯。水量很重要根据杯子的数量加入茶粉。你可以每杯加一茶匙。如果你想要茶更浓,那么加入更多的粉末。如果你想要保持清淡,减少茶粉的含量。现在根据你的味蕾添加糖。\\ n \\ n将混合物煮沸。当你在混合物中看到微红色调时停止。进一步煮沸会给它带来苦涩的味道。解开并倒入杯子里。给牛奶加温牛奶。对于没有牛奶的茶,加入一些生姜滴或酸橙,根据你的喜好,你很懒,你想要一台电脑为你做一杯茶...哈哈哈...... 。这是什么食物让你自己哈哈哈哈);
}
else
printf( );

}
if (answer2 == 1

{
printf( \ nOH上帝!\ n \\ n \\ n \\ n \\ n \\ n \\ n预订我变得如此肥胖......你仍然不要因为要我为你做点东西而感到羞耻。不要加入一个健身房!);
}
else
printf( );


}
if (answer1 == 2

{
printf( 哦%s,如果你什么都不想要的话吃...然后我毫无用处......因为我只擅长为我的主人做点什么。如果你想让我为你做任何事情,那就不用了。\ n只是,再次运行程序!谢谢%s ... \ nHAVE好日子,姓名,姓名);
}
else
printf( );
}



感谢您的帮助!祝你今天愉快! :)


Can you please tell me what's wrong in my code. The program crashes after the user enters his name! Its just a program created for fun but i want to know what's wrong with it!

    #include<<stdio.h>>
#include<<conio.h>>
int main()
{
    char name;
    int answer1;
    int answer2;
    int answer3;
    printf("What is your name?\n");
    scanf("%s", name);
    printf("\nOh wow, What a wonderful name!\n Hello %s, What can i do for you???\n", name);
    printf("\nDo you want me to make something for you???[YES=1 OR NO=2]\n");
    scanf("%d",&answer1);
    if(answer1==1)
    {

        printf("\n Do you want something to eat or do you want something to drink???\n[EAT=1 OR DRINK=2]\n");
        scanf("%d",&answer2);
        if(answer2==2)
        {

            printf("I can make a coffee or a cup of tea for you!\n What do you prefer?[coffee=1 or tea=2]");
            scanf("%d",&answer3);
            if(answer3==1)
            {
                printf("\nHere is the recipe:\n");
                printf("The Right Equipment\nCarguilo likes the clean, robust taste that comes from a manual dripper, since it filters out oil and sediment. And she’s not alone. As basic as it is, the pour-over has become the latest thing at gourmet coffee shops. Cone-shaped drippers work fine, but Carguilo prefers the flat base of the Kalita Wave (shown at right, $38; filters, $13 for 100: shop.wreckingball coffee.com). "The grounds lie evenly, so the water saturates them equally," says Carguilo.\nThe Right Water\nIf you don’t like the flavor of your tap water, use filtered or bottled.\n\nFresh Grounds\nGrind beans within a half hour of brewing. A burr grinder is ideal but pricey ($50 or more). It creates uniform grounds and prevents the coffee from ending up too weak or too bitter. For a manual dripper, medium size (similar to raw sugar granules) is best. (Learn how to choose the best gourmet coffee beans.)\nMagic Ratio\nTo brew 16 ounces of coffee (two big cups), use 5 tablespoons (or 28 grams) of coffee and 16 ounces of water.\nMaster the Pour-Over\n\n\nTotal brew time: 3 to 5 minutes\n1. As your kettle heats, place a dripper lined with a paper filter on a mug or a carafe. Rinse the filter with hot water to get rid of paper dust and to preheat the cone.\n2. Place ground coffee in the dampened filter.\n3. After the water boils, wait 10 seconds for it to settle. Slowly pour just enough hot water (in a circular motion) to saturate all the grounds.\n4. Pause 30 seconds to let the coffee "bloom." It will bubble and soften.\n5. Pour again, raising the water level to an inch above the grounds. Wait a few moments until\nthe water trickles through the dripper. Repeat this process of "pulse pouring," which helps prevent overflow, until you have your desired amount of brewed coffee\n.");
                printf("\n\nHAHAHAHAHAHHAHA...here's the recipe...go make it yourself. DAMN...you are so lazy that you want a computer to make a coffee for you hahahahaha!");

            }
            if(answer3==2)
                {
                    printf("Boil water.\n Take 3/4th cup for every cup you want to make. The measure of water is important for the taste you want to achieve\n\nNow add tea powder according to number of cups. You can take one teaspoon per cup. If you want the tea to be strong then add more powder. If you wish to keep it light lessen the amount of tea powder\n\nNow add sugar as per your taste buds.\n\nBring the mixture to a boil. Stop when you see a reddish tinge in the concoction. Boiling further would give it a bitter taste.\n\nSieve and pour in cups.\n\nAdd warm milk for milk tea. For tea without milk add some ginger drops or lime, according to your preference\n\n\nHAHAHHHAHAHA...you are so lazy that you want a computer to make a cup of tea for you...HAHAhA...here'sthe recipe\n\nGO MAKE IT YOURSELF HAHAHAHAHHA");
                }
                else
                    printf("");

        }
        if(answer2==1)

            {
                printf("\nOH GOD!!!\n\n\n\nLOOK AT YOU\n\nYou've become so fat...still you dont feel ashamed of asking me to make something for you to eat\n\nGO JOIN A GYM!");
            }
            else
                printf("");


    }
    if(answer1==2)

        {
            printf("Oh %s, if you want nothing to eat...then im of no use...\nbecause i am only good at making something for my master\n\nif you want me to make anything for you;\nsimply, run the program again!Thank you %s...\nHAVE A GOOD DAY", name, name);
        }
        else
            printf("");
}


Thank You for your help! Have a nice day! :)

解决方案

38; filters,


13 for 100: shop.wreckingball coffee.com). "The grounds lie evenly, so the water saturates them equally," says Carguilo.\nThe Right Water\nIf you don’t like the flavor of your tap water, use filtered or bottled.\n\nFresh Grounds\nGrind beans within a half hour of brewing. A burr grinder is ideal but pricey (


50 or more). It creates uniform grounds and prevents the coffee from ending up too weak or too bitter. For a manual dripper, medium size (similar to raw sugar granules) is best. (Learn how to choose the best gourmet coffee beans.)\nMagic Ratio\nTo brew 16 ounces of coffee (two big cups), use 5 tablespoons (or 28 grams) of coffee and 16 ounces of water.\nMaster the Pour-Over\n\n\nTotal brew time: 3 to 5 minutes\n1. As your kettle heats, place a dripper lined with a paper filter on a mug or a carafe. Rinse the filter with hot water to get rid of paper dust and to preheat the cone.\n2. Place ground coffee in the dampened filter.\n3. After the water boils, wait 10 seconds for it to settle. Slowly pour just enough hot water (in a circular motion) to saturate all the grounds.\n4. Pause 30 seconds to let the coffee "bloom." It will bubble and soften.\n5. Pour again, raising the water level to an inch above the grounds. Wait a few moments until\nthe water trickles through the dripper. Repeat this process of "pulse pouring," which helps prevent overflow, until you have your desired amount of brewed coffee\n."); printf("\n\nHAHAHAHAHAHHAHA...here's the recipe...go make it yourself. DAMN...you are so lazy that you want a computer to make a coffee for you hahahahaha!"); } if(answer3==2) { printf("Boil water.\n Take 3/4th cup for every cup you want to make. The measure of water is important for the taste you want to achieve\n\nNow add tea powder according to number of cups. You can take one teaspoon per cup. If you want the tea to be strong then add more powder. If you wish to keep it light lessen the amount of tea powder\n\nNow add sugar as per your taste buds.\n\nBring the mixture to a boil. Stop when you see a reddish tinge in the concoction. Boiling further would give it a bitter taste.\n\nSieve and pour in cups.\n\nAdd warm milk for milk tea. For tea without milk add some ginger drops or lime, according to your preference\n\n\nHAHAHHHAHAHA...you are so lazy that you want a computer to make a cup of tea for you...HAHAhA...here'sthe recipe\n\nGO MAKE IT YOURSELF HAHAHAHAHHA"); } else printf(""); } if(answer2==1) { printf("\nOH GOD!!!\n\n\n\nLOOK AT YOU\n\nYou've become so fat...still you dont feel ashamed of asking me to make something for you to eat\n\nGO JOIN A GYM!"); } else printf(""); } if(answer1==2) { printf("Oh %s, if you want nothing to eat...then im of no use...\nbecause i am only good at making something for my master\n\nif you want me to make anything for you;\nsimply, run the program again!Thank you %s...\nHAVE A GOOD DAY", name, name); } else printf(""); }


Thank You for your help! Have a nice day! :)


这篇关于我的代码有什么不对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆