当我运行我的程序时,我得到这个:
run:
Heat Index: Key West, Florida
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
____________________________________________________________________________________________________________________________________
Temperature: 70.3 70.8 73.8 77.0 80.7 83.4 84.5 84.4 83.4 80.2 76.3 72.0
Humidity: 69.0 67.0 66.0 64.0 66.0 69.0 67.0 67.0 70.0 69.0 69.0 70.0BUILD SUCCESSFUL (total time: 0 seconds)
Run Code Online (Sandbox Code Playgroud)
我想显示此内容,以便月份与每一列数字对齐,例如 Jan 与第一列数字对齐,依此类推。我知道如果月份对齐的话,每列数字之间有 7 个空格。问题是,我不知道如何使用 printf 创建空白,例如空白,因此月份不会显示在温度:标题的顶部。任何帮助将不胜感激。
我有一个关于如何在终端Mac中编译C++程序的问题.我的程序有一个头文件和一个主文件.我知道我无法编译头文件和主文件.并只是编译主文件.我也知道我需要创建一个名称来存储编译文件.这是我使用的编译命令,g++ -o execute1 main.cpp我得到了这个:
Undefined symbols for architecture x86_64:
"add(int, int)", referenced from:
_main in main-f2nZvj.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?任何帮助将不胜感激.如果有帮助,下面是我的两个文件的代码:
add.h:
int add(int x, int y);
Run Code Online (Sandbox Code Playgroud)
main.cpp中:
#include <iostream>
#include "add.h"
int main(){
using namespace std;
cout << "The sum of 9 and 9 is " << add(9, 9) << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)