The document contains code snippets from C and C++ programs. It includes code defining variables, using loops and functions, parsing configurations, and calculating remainders with the Euclid's algorithm. Pseudocode is also presented for Euclid's algorithm to calculate the greatest common divisor.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
62 views2 pages
C Odigo:: #Include #Define
The document contains code snippets from C and C++ programs. It includes code defining variables, using loops and functions, parsing configurations, and calculating remainders with the Euclid's algorithm. Pseudocode is also presented for Euclid's algorithm to calculate the greatest common divisor.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
Código:
1 # include < stdio .h >
2 # define N 10 3 /* Block 4 * comment */ 5 int main () { 6 int i ; 7 // Line comment . 8 puts ( " Hello world ! " ) ; 9 10 for ( i = 0; i < N ; i ++) 11 puts ( " LaTeX is also great for programmers ! " ) ; 12 return 0; 13 }
Código desde archivo:
1 2 // print i n f o r m a t i o n 3 fprintf ( stdout , " \ n " ) ; 4 fprintf ( stdout , " HM software : Encoder Version [ %s ] ( including RExt ) " , NV_VERSION ) ; 5 fprintf ( stdout , NVM_ONOS ) ; 6 fprintf ( stdout , NVM_COMP ILEDBY ) ; 7 fprintf ( stdout , NVM_BITS ) ; 8 fprintf ( stdout , " \ n \ n " ) ; 9 10 // create a p p l i c a t i o n encoder class 11 cTAppEncTop . create () ; 12 13 // parse c o n f i g u r a t i o n 14 try 15 { 16 if (! cTAppEncTop . parseCfg ( argc , argv ) ) 17 { 18 cTAppEncTop . destroy () ; 19 # if E N V I R O N M E N T _ V A R I A B L E _ D E B U G _ A N D _ T E S T 20 EnvVar :: printEnvVar () ; 21 # endif 22 return 1; 23 } 24 } 25 catch ( df :: p r o g r a m _ o p t i o n s _ l i t e :: ParseFailure & e ) 26 { 27 std :: cerr << " Error parsing option \" " << e . arg <<" \" with argument \" " << e . val <<" \". " << std :: endl ; 28 return 1; 29 } 30 31 # if P R I N T _ M A C R O _ V A L U E S 32 p r i n t M a c r o S e t t i n g s () ; 33 # endif 34 35 # if E N V I R O N M E N T _ V A R I A B L E _ D E B U G _ A N D _ T E S T 36 EnvVar :: p r i n t En v V a r I n U s e () ; 37 # endif
1 38 39 // s t a r t i n g time 40 Double dResult ; 41 clock_t lBefore = clock () ;
Pseudocódigo:
Algorithm 1 Euclid’s algorithm
1: procedure Euclid(a, b) . The g.c.d. of a and b 2: r ← a mód b 3: while r 6= 0 do . We have the answer if r is 0 4: a←b 5: b←r 6: r ← a mód b 7: end while 8: return b . The gcd is b 9: end procedure