yunqi_zhang
deepin
2020-11-19 05:38 我是直接用控制台运行的
Reply Like 0 View the author
我是直接用控制台运行的
你的 for 循环没写开始条件或者初始值吧......
#include
#include
#include
using namespace std;
int main()
{
vector a;
cout << "请输入:" << endl;
int b;
cin >> b;
for(int i = 0; i < b; i++)
{
int c;
cin >> c;
a.push_back(c);
}
int max = a[0];
for(int i = 0; i < b; i++)
{
if(max < a[i])
{
max = a[i];
}
}
cout << max << endl;
cin.get();
cout << endl << "Press any key to continue..." << endl;
cin.get();
return 0;
}这样好像没啥问题,编译可以用 g++ -o 输出文件名 源文件路径 来指定输出文件名。
你i没赋值啊,老师该打你屁股了
你现在是用codeblock的吧,等你学会cpp一定要学习vim写cpp,vim天下第一
你现在是用codeblock的吧,等你学会cpp一定要学习vim写cpp,vim天下第一
vim/emacs是上个世纪的东西
人生苦短,vscode吧
set nocompatible "Turn off compatibility mode with Vi
set number "Show Line Numbers
set nowrap "No automatic folding
set showmatch "Display matching parentheses
set encoding=utf-8
set fenc=utf-8
set ts=4
set mouse=a "To enable the mouse
set hlsearch "Search highlight
syntax enable "Syntax highlighting
set tabstop=4 "TAB equivalent space length
set softtabstop=4
set expandtab
set autoindent "Automatic indentation
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'davidhalter/jedi-vim'
Plugin 'w0rp/ale'
Plugin 'gaalcaras/ncm-R'
Plugin 'tpope/vim-fugitive'
Plugin 'Shougo/neocomplete.vim'
Plugin 'jalvesaq/Nvim-R'
Plugin 'chrisbra/csv.vim'
Plugin 'ncm2/ncm2'
Plugin 'roxma/nvim-yarp'
Plugin 'roxma/vim-hug-neovim-rpc'
Plugin 'sirver/UltiSnips'
Plugin 'ncm2/ncm2-ultisnips'
Plugin 'Valloric/YouCompleteMe'
Plugin 'godlygeek/tabular'
Plugin 'hdima/python-syntax'
Plugin 'lervag/vimtex'
Plugin 'xuhdev/vim-latex-live-preview'
Plugin 'calviken/vim-gdscrīpt3'
Plugin 'skywind3000/asyncrun.vim'
Plugin 'humiaozuzu/dot-vimrc'
Plugin 'artur-shaik/vim-javacomplete2'
Plugin 'preservim/nerdtree'
Plugin 'Lokaltog/vim-powerline'
Plugin 'vim-scrīpts/javacomplete'
Plugin 'tpope/vim-commentary'
Plugin 'vim-syntastic/syntastic'
Plugin 'preservim/tagbar'
Plugin 'vim-airline/vim-airline'
Plugin 'walm/jshint.vim'
Plugin 'pangloss/vim-javascrīpt'
Plugin 'jamescarr/snipmate-nodejs'
Plugin 'myhere/vim-nodejs-complete'
Plugin 'guileen/vim-node'
Plugin 'fatih/vim-go'
call vundle#end()
filetype plugin indent on
set backspace=indent,eol,start
"Mode Settings
let &t_SI.="\e[5 q" "SI = INSERT mode
let &t_SR.="\e[4 q" "SR = REPLACE mode
let &t_EI.="\e[1 q" "EI = NORMAL mode (ELSE)
"Cursor settings:
" 1 -> blinking block
" 2 -> solid block
" 3 -> blinking underscore
" 4 -> solid underscore
" 5 -> blinking vertical bar
" 6 -> solid vertical bar
"let &t_SI = "\]50;CursorShape=1\x7"
"let &t_SR = "\]50;CursorShape=2\x7"
"let &t_EI = "\]50;CursorShape=0\x7"
"set guicursor=n-c-v:ver1000-ncvCursor
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
let g:ale_sign_column_always = 1
let g:ale_set_hightlights = 1
let g:ale_sign_error = 'x'
let g:ale_sign_warning = '!'
let g:ale_linters = { 'python':['pylint']}
let g:syntastic_python_checkers=['python3.8.5']
let g:ncm_r_column_layout = 0
"let g:vimtex_latexmk_options='-pdf -pdflatex="xelatex -synctex=1 \%S \%O" -verbose -file-line-error -interaction=nonstopmode'
let g:tex_flavor='latex'
let g:vimtex_view_method='skim'
let g:vimtex_quickfix_mode=0
set conceallevel=1
let g:tex_conceal='abdmg'
let g:asyncrun_open = 6
let g:asyncrun_bell = 1
map :call asyncrun#quickfix_toggle(6)
nmap :TagbarToggle
map :call CompileRunGcc()
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!time java %<"
elseif &filetype == 'sh'
:!time bash %
elseif &filetype == 'python'
exec "!time python %"
elseif &filetype == 'html'
exec "!/opt/apps/org.mozilla.firefox-nal/files/firefox % &"
elseif &filetype == 'go'
exec "!go build %<"
exec "!time go run %"
elseif &filetype == 'mkd'
exec "!~/.vim/markdown.pl % > %.html &"
exec "!/opt/apps/org.mozilla.firefox-nal/files/firefox %.html &"
elseif &filetype == 'tex'
exec "!evince %:r.pdf &"
elseif &filetype == 'lua'
exec "!time lua %"
endif
endfunc我的vim配置文件,希望对你有些帮助2333,可以自动cpp补全
vim/emacs是上个世纪的东西
人生苦短,vscode吧
上世纪??您对vim偏见是有多大啊
代码中至少存在的问题:
…… // #include // 此代码用不到,且 stdlib.h 是C形式的……for (int i = 0; i < b; i++) { // i 没赋初值……int max = a[0]; // max 也没赋初值for (int d = 0; d < b; d++) { // d 没赋初值……cout << max << endl; // 输出没换行,默认行缓冲(换行才输出)// while(true); // 没啥用,这行死循环,程序不退出,导致上一行迟迟没输出……
编译运行:
g++ main.cpp && ./a.out # 假设文件名是 main.cpp我早点看到这个帖子也不用绕那么大的弯了
你现在是用codeblock的吧,等你学会cpp一定要学习vim写cpp,vim天下第一
用VIM写,老黄历了吧
用VIM写,老黄历了吧
vim可以debug直接运行,关键是有丰富的命令生态,比如正则化,这些是ide提供不了的
vim可以debug直接运行,关键是有丰富的命令生态,比如正则化,这些是ide提供不了的
正则化是啥,正则搜索替换吗![[喜欢]](/assets/image/raccoon/[like].gif)
你的 for 循环没写开始条件或者初始值吧......
#include
#include
#include
using namespace std;
int main()
{
vector a;
cout << "请输入:" << endl;
int b;
cin >> b;
for(int i = 0; i < b; i++)
{
int c;
cin >> c;
a.push_back(c);
}
int max = a[0];
for(int i = 0; i < b; i++)
{
if(max < a[i])
{
max = a[i];
}
}
cout << max << endl;
cin.get();
cout << endl << "Press any key to continue..." << endl;
cin.get();
return 0;
}这样好像没啥问题,编译可以用 g++ -o 输出文件名 源文件路径 来指定输出文件名。
谢谢大佬,刚改lin,以前都算用vc的,不知道有这摩多规矩
Popular Ranking
ChangePopular Events
More
lin新手求如何运行自己做的c++控制台应用,已经g++汇编成.a文件了,但cin>>好像有些问题:
#include
#include
#include
using namespace std;
int main(){
vector a;
cout<<"请输入";
int b;
cin>>b;
for (int i;i int c;
cin>>c;
a.push_back(c);
}
int max;
for(int d;d if(max }
cout< while(true);
return 0;
}
注释:这是我写的测试程序