我正在尝试在代码块 IDE 中成为明星。为了创建星星,我尝试合并“ \”反斜杠,但是当我构建并运行程序时,反斜杠被省略。
#include <iostream>
int main() {
std::cout << " /\\ " << '\n';
std::cout << "< >" << '\n';
std::cout << "//\\" << '\n';
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在网上查找了一个解决方案,建议使用两个反斜杠,因为反斜杠是一个“可执行文件”(定义可能错误)。该解决方案确实适用于第一行,但星形的末端缺少一条腿,有什么想法为什么吗?
我还尝试了最后一行的三重反斜杠,但我遇到了同样的问题。
在另一个问题中有人要求发布makefile.这些位于何处?或者我怎样才能找到我的文件,以便发布它们?
我正在学习C,却遇到了一个奇怪的问题。我想我了解多个if和else-if语句之间的区别,但是这次我根本无法理解行为上的区别。如果我删除else关键字,则它按预期工作,但不包含else。
该代码是关于在不区分大小写的情况下对每个字母的出现进行计数的(因此,“ a”和“ A”都被视为字母“ a”的出现次数)。
我尽力去掉括号,但什么也没改变,所以我把它们留在里面以避免警告。
while ((c = getchar()) != EOF)
{
if ('A' < c < 'Z')
{
++array[c - 'A'];
}
else if ('a' < c < 'z')
{
++array[c - 'a'];
}
}
Run Code Online (Sandbox Code Playgroud)
当我键入“ a”时,数组不会递增,但是如果删除else语句,从而切换到if倍数的情况,它将按预期工作。在两种情况下,字母“ A”都会很好地更新数组。
您能否帮助我了解这种情况下的行为差异?
我只是试图使用sin,cos和sqrt功能,但我不断收到错误消息“在此范围内没有宣布”。我已经查看了错误的所有搜索结果,并且 1. 编码人员正在使用终端来编译他们的代码(而不是我正在使用的 CodeBlocks) 2. 我已经尝试使用cmath,添加using namespace std和使用绝对路径。我越来越沮丧。
#ifndef _MATH_H
#define _MATH_H
#include </usr/include/math.h>
#define PI 3.14159265
#define DEG_TO_RAD PI / 180.0f
struct Vector2
{
float x;
float y;
Vector2(float _x = 0.0f, float _y = 0.0f)
: x(_x), y(_y) {}
float MagnitudeSqr()
{
return x*x + y*y;
}
float Magnitude()
{
return (float)sqrt(x*x + y*y);
}
Vector2 Normalized()
{
float mag = Magnitude();
return Vector2(x/ mag, y /mag);
} …Run Code Online (Sandbox Code Playgroud) 我在codeblocks上测试了这段代码并且工作正常但是当我在Ideone上运行时,我在OJ上遇到运行时错误和SIGSEGV错误.我在网上看到SIGSEGV错误是由于内存访问受限造成的.但如果它这样做,为什么不是代码块抱怨......
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
int t, i, j, k, x, temp;
int num1[10000], num2[10000];
char c;
bool f = true;
cin >> t;
while (t--)
{
for (i = 0; i < 10000; i++)
{
num1[i] = 0;
num2[i] = 0;
}
i = 0;
j = 0;
while (!isspace(c = getchar()))
num1[i++] = c - '0';
while (!isspace(c = getchar()))
num2[j++] = c - '0';
x = i > j ? i : …Run Code Online (Sandbox Code Playgroud) 不知道我的问题在哪里.我尝试编译一次代码并且它有效.但是,我将它复制到一个新项目中以便修改它,只是颜色或等待的时间,它只适用于第一个程序.怎么了?我感到非常沮丧.使用此代码,我想绘制正弦函数.这是我的代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t,n1,n2,res=0;
cin>>t;
vector<int> v1;
vector<int> v2;
while (t--) {
cin>>n1>>n2;
v1.push_back(n1);
v2.push_back(n2);
}
for (int i=v1.size();i>0;i++) {
bool state=binary_search(v2.begin(),v2.end(),v1[i-1]);
if (state){
v1.pop_back();
res++;
}
}
cout<<res<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我正在学习c pragramming,当我尝试在引文中打印"Hello World"时,我收到一个错误:
id返回1退出状态
这是我的代码,我正在使用codeblock:
#include <stdio.h>
int main()
{
printf("\"Hello World\" ");
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我正在学习c ++,并且正在使用Visual Studios,但我今天切换到代码块并遇到了麻烦.我的编译器是MinGW,如果这很重要的话.无论如何,我做了一个看起来像这样的练习程序:
#include <iostream>
using namespace std;
Int main()
{
Int x;
cin >> x;
If(x == 1)
Exit(0)
Return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我构建它时,我在包含Exit(0)的行上出现错误.为什么是这样?另外,如何让底部的构建/调试工具栏重新出现?
我在网上做了一些研究,但没有找到-1073741676Code::Blocks 显示的错误代码的解释。
确切的错误消息是Process terminated with status -1073741676 (0 minute(s), 8 second(s))。
对于这个精确的状态是否有一个全局的、恒定的解释,或者它是否会随着编译器、IDE 或任何其他变量的变化而改变?
\n\n代码(尽可能少):
\n\n主程序
\n\n int n(0), choix(0);\n string dis;\n // Nobel* laureats = saisie(n); // Saisie \xc3\xa0 la main\n\n Nobel* laureats = lecture(n);\n cin >> dis;\n cout << agemoyen(laureats, n, dis) << endl;\nRun Code Online (Sandbox Code Playgroud)\n\n诺贝尔.h
\n\n#ifndef NOBEL_H_INCLUDED\n#define NOBEL_H_INCLUDED\n\n#include <string>\n\n\nstruct Nobel\n{\n std::string nom, discipline;\n int annee, age;\n std::string pays;\n};\nint agemoyen(Nobel* NO, int n, std::string dis);\nNobel* lecture(int& n);\n\n#endif // NOBEL_H_INCLUDED\nRun Code Online (Sandbox Code Playgroud)\n\n … 我正在尝试在代码块中编译这个简单的C++程序:
#include <string>
#include <fstream>
#include <streambuf>
#include <sstream>
std::ifstream t("C:/Windows/System32/drivers/etc/hosts-backup.txt");
std::stringstream buffer;
buffer << t.rdbuf();
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
|| === Build:在hostapp2中调试(编译器:GNU GCC编译器)=== |
C:\ Users\Flights Trainer\Desktop\hostapp2\main.cpp | 7 |错误:'缓冲'不命名类型
|| ===构建失败:1个错误,0个警告(0分钟,0秒(s))=== |
我一整天都在谷歌搜索"没有命名类型",我发现的所有内容都指向在宣布之前使用类,但我不明白我在做什么.
我究竟做错了什么?