Professional Documents
Culture Documents
•
–
–
•
–
–
•
– main
– int
–
main_program{ xxx }, y int main(){ xxx }
• main_program int main()
•
• main
–
• main_program main
•
•
–
–
–
•
–
•
–
•
–
•
–
•
•
•
•
–
–
–
🎻
•
–
•
–
•
–
•
•
• int gcd(int m, int n);
• int gcd(int, int);
• gcd
–
•
–
–
•
•
• •
int gcd(int m, int n){ … } •
•
•
int gcd(int, int); •
int lcm(int m, int n){
return m*n/gcd(m,n);} •
•
•
int lcm(int, int);
int main(){ •
cout << lcm(36,24) << endl; •
}
• •
#include “gcdlcm.h”
• int gcd(int m, int n){ … }
• •
int gcd(int, int); #include “gcdlcm.h”
int lcm(int,int); int lcm(int m, int n){ … }
• #include filename •
–
#include <simplecpp>
–
#include “gcdlcm.h”
– int main(){ ...}
•
•
simplecpp
•
•
•
•
•
🎻
•
–
•
•
•
• f N N::f
• f N P
– N::f P::f
namespace N{
declarations/definition of names
}
• N
• N
namespace N{ }
• g
::g
namespace N{
int gcd(int m, int n){ … }
int lcm(int m, int n){ … }
}
int main(){
cout << N::lcm(36,24) << endl;
}
using
• N
– N::
•
using namespace N;
• N
N::
using
namespace N{
int gcd(int m, int n){ … }
int lcm(int m, int n){ … }
}
using namespace N;
int main(){
cout << lcm(36,24) << endl;
}
•
–
• using
•
–
–
🎻
• simplecpp
• #include <simplecpp>
#include <iostream>
#include <cmath>
using namespace std;
•
– cin, cout, endl std
iostream
• simplecpp
• cmath sqrt, sin, abs.
#include <iostream> #include <iostream>
using namespace std;
int main(){
int main(){ int n;
int n; std::cin >> n;
cin >> n; std::cout << n*n*n <<
cout << n*n*n << std::endl;
endl; }
}
•
–
•
–
•
•
•
•
•
•
•
🎻🎻