Language: C++

Last login: Fri Oct 11 10:11:46 on console
pc026030m:~ 8289423578$ vim
pc026030m:~ 8289423578$ vim test.cpp
pc026030m:~ 8289423578$ cp test.cpp > init.cpp
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory
pc026030m:~ 8289423578$ cp test.cpp init.cp
pc026030m:~ 8289423578$ cp test.cpp init.cpp
pc026030m:~ 8289423578$ rm init.cp
pc026030m:~ 8289423578$ ls 
#exl.awk#		eular.dat		nbody2_anim
1.2			eular_1			nbody2_anim.cpp
1.2.cpp			eular_1.cpp		nbody2_anim.cpp~
1.2.cpp~		eular_1.dat		nbody2_anim.dat
1.2.dat			euler_2			nbody2_anim.o
Applications		euler_2.cpp		ngc1754.dat
Desktop			euler_2.cpp~		one_body
Documents		euler_2.dat		one_body.cpp
Downloads		euler_3			one_body.cpp~
Library			euler_3.cpp		one_body.dat
Makefile		euler_3.cpp~		pgplot.sh
Makefile~		euler_3.dat		pleasepe.dat
Movies			eusar_1			pleiades.awk
Music			example.data		pleiades.dat
Pictures		example.data~		pleseve.dat
Public			exl			preasepe
Untitled.ipynb		exl.awk			preasepe.awk
Untitled1.ipynb		exl.cpp			preasepe.dat
Untitled10.ipynb	galaxy.awk		preasepe~
Untitled2.ipynb		galaxy.awk~		real_velocity..dat
Untitled3.ipynb		galaxy.dat		real_velocity.awk
Untitled4.ipynb		galaxy.dat~		real_velocity.dat
Untitled5.ipynb		hr25pc.awk		sdss.awk
Untitled6.ipynb		hr25pc.awk~		sdss.awk~
Untitled7.ipynb		hr25pc.dat		sdss.dat
Untitled8.ipynb		init.cpp		sefide.awk
Untitled9.ipynb		kadai5			sefide.awk~
a.awk			kadai5.cpp		sefide.dat
a.out			kadai5.cpp~		sennsinnkagaku1.ipynb
a.out.dSYM		kadai5.dat		setting.plt
aaa			lec02.pdf		setting.plt~
cfa.awk			lec03.pdf		test.cpp
cfa.awk~		lec05.pdf		unicircle
cfa.dat			lec06.pdf		unicircle.cpp
circle			lec07.pdf		unicircle.cpp~
circle.cpp		lec08.pdf		unicircle.dat
circle.cpp~		lec10.pdf		vi.awk
circle.o		lec11.dat		vi.awk~
d1			lec11.pdf		vi.dat
demo.cpp		lec13.pdf
emacs			nbody
pc026030m:~ 8289423578$ find -name init.cpp
find: illegal option -- n
usage: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
       find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
pc026030m:~ 8289423578$ cat init.cpp
#include<iostream>
using namespace std;
int main(){
	return 0;
}
pc026030m:~ 8289423578$ vim test.cpp
pc026030m:~ 8289423578$ g++ test.cp
clang: error: no such file or directory: 'test.cp'
clang: error: no input files
pc026030m:~ 8289423578$ g++ test.cpp
test.cpp:3:24: error: implicit instantiation of undefined template
      'std::__1::vector<int, std::__1::allocator<int> >'
void subset(vector<int>a,int i){
                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:200:28: note: 
      template is declared here
class _LIBCPP_TEMPLATE_VIS vector;
                           ^
test.cpp:4:8: error: use of undeclared identifier 'n'
        if(i==n){
              ^
test.cpp:5:15: error: expected '(' for function-style cast or type construction
                foreach(int i:a)cout<<i<<" ";
                        ~~~ ^
test.cpp:15:13: error: implicit instantiation of undefined template
      'std::__1::vector<int, std::__1::allocator<int> >'
        vector<int>a;
                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:200:28: note: 
      template is declared here
class _LIBCPP_TEMPLATE_VIS vector;
                           ^
4 errors generated.
pc026030m:~ 8289423578$ vim test.cpp 
pc026030m:~ 8289423578$ g++ test.cpp
test.cpp:5:8: error: use of undeclared identifier 'n'
        if(i==n){
              ^
test.cpp:6:15: error: expected '(' for function-style cast or type construction
                foreach(int i:a)cout<<i<<" ";
                        ~~~ ^
2 errors generated.
pc026030m:~ 8289423578$ vim test.cpp 
pc026030m:~ 8289423578$ g++ test.cpp
test.cpp:4:32: error: unknown type name 'n'
void subset(vector<int>a,int i,n){
                               ^
test.cpp:5:8: error: use of undeclared identifier 'n'
        if(i==n){
              ^
test.cpp:6:15: error: expected '(' for function-style cast or type construction
                foreach(int i:a)cout<<i<<" ";
                        ~~~ ^
test.cpp:8:16: error: use of undeclared identifier 'n'
                subset(a,i+1,n);
                             ^
test.cpp:10:16: error: use of undeclared identifier 'n'
                subset(a,i+1,n);
                             ^
5 errors generated.
pc026030m:~ 8289423578$ vim test.cpp 
pc026030m:~ 8289423578$ g++ test.cpp
test.cpp:6:12: warning: range-based for loop is a C++11 extension
      [-Wc++11-extensions]
                for(int i:a)cout<<i<<" ";
                         ^
1 warning generated.
pc026030m:~ 8289423578$ vim test.cpp 
pc026030m:~ 8289423578$ g++ test.cpp
test.cpp:6:13: error: expected ';' in 'for' statement specifier
                for(int i in a)cout<<i<<" ";
                          ^
test.cpp:6:13: error: unknown type name 'in'
test.cpp:6:16: error: variable declaration in condition must have an initializer
                for(int i in a)cout<<i<<" ";
                             ^
3 errors generated.
pc026030m:~ 8289423578$ vim test.cpp 
pc026030m:~ 8289423578$ g++ test.cpp
test.cpp:6:15: error: expected '(' for function-style cast or type construction
                foreach(int i in a)cout<<i<<" ";
                        ~~~ ^
1 error generated.
pc026030m:~ 8289423578$ cp init.cpp test.cpp
pc026030m:~ 8289423578$ vim test.cpp
pc026030m:~ 8289423578$ g++ test.cpp
test.cpp:5:24: error: C++ requires a type specifier for all declarations
vector<int> eat(const &vector<int>candy,int candy_max,int &sum){
                ~~~~~  ^
test.cpp:5:24: error: 'vector' cannot be the name of a parameter
test.cpp:5:35: error: expected ')'
vector<int> eat(const &vector<int>candy,int candy_max,int &sum){
                                  ^
test.cpp:5:16: note: to match this '('
vector<int> eat(const &vector<int>candy,int candy_max,int &sum){
               ^
test.cpp:6:4: error: use of undeclared identifier 'candy'
if(candy.size()==0)
   ^
test.cpp:7:20: error: expected '(' for function-style cast or type construction
        return vector<int>;
               ~~~~~~~~~~~^
test.cpp:9:8: error: use of undeclared identifier 'candy'
        while(candy[candy.size()-1]+candy[candy.size()-2]>candy_max){
              ^
test.cpp:9:14: error: use of undeclared identifier 'candy'
        while(candy[candy.size()-1]+candy[candy.size()-2]>candy_max){
                    ^
test.cpp:9:30: error: use of undeclared identifier 'candy'
        while(candy[candy.size()-1]+candy[candy.size()-2]>candy_max){
                                    ^
test.cpp:9:36: error: use of undeclared identifier 'candy'
        while(candy[candy.size()-1]+candy[candy.size()-2]>candy_max){
                                          ^
test.cpp:9:52: error: use of undeclared identifier 'candy_max'
        while(candy[candy.size()-1]+candy[candy.size()-2]>candy_max){
                                                          ^
test.cpp:10:6: error: use of undeclared identifier 'candy'
                if(candy[candy.size()-2]>0){
                   ^
test.cpp:10:12: error: use of undeclared identifier 'candy'
                if(candy[candy.size()-2]>0){
                         ^
test.cpp:11:4: error: use of undeclared identifier 'candy'
                        candy[candy.size()-2]--;
                        ^
test.cpp:11:10: error: use of undeclared identifier 'candy'
                        candy[candy.size()-2]--;
                              ^
test.cpp:12:4: error: use of undeclared identifier 'sum'
                        sum++;
                        ^
test.cpp:14:4: error: use of undeclared identifier 'candy'
                        candy[candy.size()-1]--;
                        ^
test.cpp:14:10: error: use of undeclared identifier 'candy'
                        candy[candy.size()-1]--;
                              ^
test.cpp:15:4: error: use of undeclared identifier 'sum'
                        sum++;
                        ^
test.cpp:18:2: error: use of undeclared identifier 'candy'
        candy.pop_back(candy[candy.size()-1]);
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
pc026030m:~ 8289423578$ vim test.cpp
pc026030m:~ 8289423578$ vim test.cpp
pc026030m:~ 8289423578$ g++ test.cpp
test.cpp:5:24: error: C++ requires a type specifier for all declarations
vector<int> eat(const& vector<int>candy,int candy_max,int &sum){
                ~~~~~  ^
test.cpp:5:24: error: 'vector' cannot be the name of a parameter
test.cpp:5:35: error: expected ')'
vector<int> eat(const& vector<int>candy,int candy_max,int &sum){
                                  ^
test.cpp:5:16: note: to match this '('
vector<int> eat(const& vector<int>candy,int candy_max,int &sum){
               ^
test.cpp:6:4: error: use of undeclared identifier 'candy'
if(candy.size()==0)
   ^
test.cpp:7:20: error: expected '(' for function-style cast or type construction
        return vector<int>;
               ~~~~~~~~~~~^
test.cpp:9:8: error: use of undeclared identifier 'candy'
        while(candy[candy.size()-1]+candy[candy.size()-2]>candy_max){
              ^
test.cpp:9:14: error: use of undeclared identifier 'candy'
        while(candy[candy.size()-1]+candy[candy.size()-2]>candy_max){
                    ^
test.cpp:9:30: error: use of undeclared identifier 'candy'
        while(candy[candy.size()-1]+candy[candy.size()-2]>candy_max){
                                    ^
test.cpp:9:36: error: use of undeclared identifier 'candy'
        while(candy[candy.size()-1]+candy[candy.size()-2]>candy_max){
                                          ^
test.cpp:9:52: error: use of undeclared identifier 'candy_max'
        while(candy[candy.size()-1]+candy[candy.size()-2]>candy_max){
                                                          ^
test.cpp:10:6: error: use of undeclared identifier 'candy'
                if(candy[candy.size()-2]>0){
                   ^
test.cpp:10:12: error: use of undeclared identifier 'candy'
                if(candy[candy.size()-2]>0){
                         ^
test.cpp:11:4: error: use of undeclared identifier 'candy'
                        candy[candy.size()-2]--;
                        ^
test.cpp:11:10: error: use of undeclared identifier 'candy'
                        candy[candy.size()-2]--;
                              ^
test.cpp:12:4: error: use of undeclared identifier 'sum'
                        sum++;
                        ^
test.cpp:14:4: error: use of undeclared identifier 'candy'
                        candy[candy.size()-1]--;
                        ^
test.cpp:14:10: error: use of undeclared identifier 'candy'
                        candy[candy.size()-1]--;
                              ^
test.cpp:15:4: error: use of undeclared identifier 'sum'
                        sum++;
                        ^
test.cpp:18:2: error: use of undeclared identifier 'candy'
        candy.pop_back(candy[candy.size()-1]);
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
pc026030m:~ 8289423578$ vim test.cpp
pc026030m:~ 8289423578$ g++ test.cpp
pc026030m:~ 8289423578$ cat test.cpp
#include<iostream>
#include<deque>
#include<algorithm>
using namespace std;
	
int main(){
	int n,max;
	cin >> n >> max;
	deque<int>candies;
	for(int i = 0;i<n;++i){
		int temp;
		cin >>temp;
		candies.push_back(temp);
	}
	int sum = 0;
	for(int j = 0;j<n;++j){
		while(candies[0]+candies[1]>max){
			if(candies[1]>0){
				candies[1]--;
				sum++;
			}else{
				candies[0]--;
				sum++;
			}
		}
		candies.pop_front();
	}
	cout <<sum;
	return 0;

}
pc026030m:~ 8289423578$ vim test.cpp

        deque<int>candies;
        for(int i = 0;i<n;++i){
                int temp;
                cin >>temp;
                candies.push_back(temp);
        }
        int sum = 0;
        for(int j = 0;j<n;++j){
                while(candies[0]+candies[1]>max){
                        if(candies[1]>0){
                                candies[1]--;
                                sum++;
                        }else{
                                candies[0]--;
                                sum++;
                        }
                }
                candies.pop_front();
        }
        cout <<sum;
        return 0;

}


Compiler output:
a.cc:11:2: error: invalid preprocessing directive #exl
   11 | #exl.awk#               eular.dat               nbody2_anim
      |  ^~~
a.cc:13:1: error: too many decimal points in number
   13 | 1.2.cpp                 eular_1.cpp             nbody2_anim.cpp~
      | ^~~~~~~
a.cc:14:1: error: too many decimal points in number
   14 | 1.2.cpp~                eular_1.dat             nbody2_anim.dat
      | ^~~~~~~
a.cc:15:1: error: too many decimal points in number
   15 | 1.2.dat                 euler_2                 nbody2_anim.o
      | ^~~~~~~
a.cc:64:42: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
   64 | clang: error: no such file or directory: 'test.cp'
      |                                          ^~~~~~~~~
a.cc:68:7: warning: multi-character literal with 48 characters exceeds 'int' size of 4 bytes
   68 |       'std::__1::vector<int, std::__1::allocator<int> >'
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:82:7: warning: multi-character literal with 48 characters exceeds 'int' size of 4 bytes
   82 |       'std::__1::vector<int, std::__1::allocator<int> >'
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:126:39: warning: multi-character character constant [-Wmultichar]
  126 | test.cpp:6:13: error: expected ';' in 'for' statement specifier
      |                                       ^~~~~
a.cc:129:41: warning: multi-character character constant [-Wmultichar]
  129 | test.cpp:6:13: error: unknown type name 'in'
      |                                         ^~~~
a.cc:146:23: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
  146 | test.cpp:5:24: error: 'vector' cannot be the name of a parameter
      |                       ^~~~~~~~
a.cc:153:51: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  153 | test.cpp:6:4: error: use of undeclared identifier 'candy'
      |                                                   ^~~~~~~
a.cc:159:51: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  159 | test.cpp:9:8: error: use of undeclared identifier 'candy'
      |                                                   ^~~~~~~
a.cc:162:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  162 | test.cpp:9:14: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:165:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  165 | test.cpp:9:30: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:168:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  168 | test.cpp:9:36: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:171:52: warning: multi-character literal with 9 characters exceeds 'int' size of 4 bytes
  171 | test.cpp:9:52: error: use of undeclared identifier 'candy_max'
      |                                                    ^~~~~~~~~~~
a.cc:174:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  174 | test.cpp:10:6: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:177:53: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  177 | test.cpp:10:12: error: use of undeclared identifier 'candy'
      |                                                     ^~~~~~~
a.cc:180:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  180 | test.cpp:11:4: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:183:53: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  183 | test.cpp:11:10: error: use of undeclared identifier 'candy'
      |                                                     ^~~~~~~
a.cc:186:52: warning: multi-character character constant [-Wmultichar]
  186 | test.cpp:12:4: error: use of undeclared identifier 'sum'
      |                                                    ^~~~~
a.cc:189:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  189 | test.cpp:14:4: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:192:53: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  192 | test.cpp:14:10: error: use of undeclared identifier 'candy'
      |                                                     ^~~~~~~
a.cc:195:52: warning: multi-character character constant [-Wmultichar]
  195 | test.cpp:15:4: error: use of undeclared identifier 'sum'
      |                                                    ^~~~~
a.cc:198:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  198 | test.cpp:18:2: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:209:23: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
  209 | test.cpp:5:24: error: 'vector' cannot be the name of a parameter
      |                       ^~~~~~~~
a.cc:216:51: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  216 | test.cpp:6:4: error: use of undeclared identifier 'candy'
      |                                                   ^~~~~~~
a.cc:222:51: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  222 | test.cpp:9:8: error: use of undeclared identifier 'candy'
      |                                                   ^~~~~~~
a.cc:225:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  225 | test.cpp:9:14: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:228:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  228 | test.cpp:9:30: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:231:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  231 | test.cpp:9:36: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:234:52: warning: multi-character literal with 9 characters exceeds 'int' size of 4 bytes
  234 | test.cpp:9:52: error: use of undeclared identifier 'candy_max'
      |                                                    ^~~~~~~~~~~
a.cc:237:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  237 | test.cpp:10:6: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:240:53: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  240 | test.cpp:10:12: error: use of undeclared identifier 'candy'
      |                                                     ^~~~~~~
a.cc:243:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  243 | test.cpp:11:4: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:246:53: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  246 | test.cpp:11:10: error: use of undeclared identifier 'candy'
      |                                                     ^~~~~~~
a.cc:249:52: warning: multi-character character constant [-Wmultichar]
  249 | test.cpp:12:4: error: use of undeclared identifier 'sum'
      |                                                    ^~~~~
a.cc:252:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  252 | test.cpp:14:4: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:255:53: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  255 | test.cpp:14:10: error: use of undeclared identifier 'candy'
      |                                                     ^~~~~~~
a.cc:258:52: warning: multi-character character constant [-Wmultichar]
  258 | test.cpp:15:4: error: use of undeclared identifier 'sum'
      |                                                    ^~~~~
a.cc:261:52: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
  261 | test.cpp:18:2: error: use of undeclared identifier 'candy'
      |                                                    ^~~~~~~
a.cc:1:1: error: 'Last' does not name a type
    1 | Last login: Fri Oct 11 10:11:46 on console
      | ^~~~
In file included from /usr/include/c++/14/iosfwd:42,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:57:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
   68 |   typedef ptrdiff_t     streamsize; // Signed integral type
      |           ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
   40 | #include <cwchar> // For mbstate_t
  +++ |+#include <cstddef>
   41 | 
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
  131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                          ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                                            ^~~~~~
In file included from /usr/include/wchar.h:35,
                 from /usr/include/c++/14/cwchar