如何将字母放入“interger”中C ++中的问题 [英] How do I put letters in "interger" problems in C++

查看:102
本文介绍了如何将字母放入“interger”中C ++中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include

 #include< iostream> 

main(){
using namespace std;
cout<< 完成数学问题。 << ENDL;
int x;
int y;
x = 5;
y = 5;
cout<< 答案是x + y<< ENDL;
cout<< 答案是x * y<< ENDL;
cout<< 答案是x / y<< ENDL;
cout<< 答案是x - 4<< ENDL;
cout<< 答案是x - 2<< ENDL;
cout<< 答案是x / 10<< ENDL;
}



这对我不起作用?

解决方案

你应该尝试更换:

 cout<<  答案是 x + y<< ENDL; 



with

 cout<<  答案是<< x + y<< ENDL; 


Quote:

这不起作用我?



因为您没有阅读文档: istream的::运营商GT;> - C ++参考 [ ^ ]。


#include

#include <iostream>

main(){
    using namespace std;
    cout << "Finish the math problem." << endl;
    int x;
    int y;
    x = 5;
    y = 5;
    cout << "The answer is" x + y << endl;
    cout << "The answer is" x * y << endl;
    cout << "The answer is" x / y << endl;
    cout << "The answer is" x - 4 << endl;
    cout << "The answer is" x - 2 << endl;
    cout << "The answer is" x / 10 << endl;
}


This doesn't work for me?

解决方案

You should try to replace:

cout << "The answer is" x + y << endl;


with

cout << "The answer is" << x + y << endl;


Quote:

This doesn't work for me?


Because you didn't read the documentation: istream::operator>> - C++ Reference[^].


这篇关于如何将字母放入“interger”中C ++中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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