The document discusses different parameter passing techniques in programming languages, including pass by value, pass by reference, and pass by result/value-result. It provides examples in languages like C, C++, Java, C#, Pascal, Ada to illustrate how each technique works and the differences between them. It also covers topics like parameter modes (in, out, in-out), parameter arrays, and variable arguments.
The new standard for C++ language has been signed in 2011. This new (extended) language, called C++11, has a number of new semantics (in terms of language constructs) and a number of new standard library support. The major language extensions are discussed in this presentation. The library will be taken up in a later presentation.
The new standard for C++ language has been signed in 2011. This new (extended) language, called C++11, has a number of new semantics (in terms of language constructs) and a number of new standard library support. The major language extensions are discussed in this presentation. The library will be taken up in a later presentation.
A minimal collection of most wanted and widely accepted idioms and coding conventions for C++ development presented with examples and explanations. The lecture targets performance oriented codes so emphasis is on performance-friendly techiques.
Topics covered:
1) Design issues: idioms and best practices
- Resource Aquisition Is Initialization (RAII)
- Ownership semantics and smart pointers
- Header files: dependencies and decoupling
2) Objects Construction/Destruction/Copying
- Designing constructors
- Rule Of Three
- Transactional programming
3) Namespaces
- ADL/Koenig Lookup
4) Static analyzers
C++20 comes with some big new language features: modules, coroutines, concepts, spaceship, and many new libraries. But apart from all those, C++20 also offers many small language improvements, making C++ more powerful and expressive, but also safer and more consistent. This talk is an overview over all those smaller additions to the core language that will make your life easier. We will discuss much-needed improvements to existing facilities such as lambdas, CTAD, structured bindings, and initialisation, as well as brand-new language utilities that you may not yet have heard about!
The presentation shows major features of the new C++ standard (language and the library). The full list of new things is very broad, so I've categorized them to be easier to understand.
Скомпилировалось — значит работает. К сожалению это выражение не про typescript. Кажется, что количество рантайм ошибок спровоцированных несоответствием типов должно стать меньше, однако компилятор ts не помогает разработчику писать качественный код, а наоборот поощряет использование грязных хаков. Филипп Сапронов рассказывает, как прекратить войну с компилятором и писать более надёжный код, используя всю мощь системы типов. Доклад будет интересен тем, кому ts кажется простым или наоборот сложным, а также тем, кто хочет научится понимать код тайпингов таких библиотек как lodash.
An introductory PowerPoint to understanding and applying the C++ programming language. Broken down into lessons covering:
Introduction: Definitions and the History of Programming
Lesson 1: Libraries, Variables and Types, Blocks and Namespaces, Functions
Lesson 2: If...Else Statements, For and While Loops, Scope
Exercise: Program a Gumball Game
Lesson 3: Classes and Objects, Pointers
A minimal collection of most wanted and widely accepted idioms and coding conventions for C++ development presented with examples and explanations. The lecture targets performance oriented codes so emphasis is on performance-friendly techiques.
Topics covered:
1) Design issues: idioms and best practices
- Resource Aquisition Is Initialization (RAII)
- Ownership semantics and smart pointers
- Header files: dependencies and decoupling
2) Objects Construction/Destruction/Copying
- Designing constructors
- Rule Of Three
- Transactional programming
3) Namespaces
- ADL/Koenig Lookup
4) Static analyzers
C++20 comes with some big new language features: modules, coroutines, concepts, spaceship, and many new libraries. But apart from all those, C++20 also offers many small language improvements, making C++ more powerful and expressive, but also safer and more consistent. This talk is an overview over all those smaller additions to the core language that will make your life easier. We will discuss much-needed improvements to existing facilities such as lambdas, CTAD, structured bindings, and initialisation, as well as brand-new language utilities that you may not yet have heard about!
The presentation shows major features of the new C++ standard (language and the library). The full list of new things is very broad, so I've categorized them to be easier to understand.
Скомпилировалось — значит работает. К сожалению это выражение не про typescript. Кажется, что количество рантайм ошибок спровоцированных несоответствием типов должно стать меньше, однако компилятор ts не помогает разработчику писать качественный код, а наоборот поощряет использование грязных хаков. Филипп Сапронов рассказывает, как прекратить войну с компилятором и писать более надёжный код, используя всю мощь системы типов. Доклад будет интересен тем, кому ts кажется простым или наоборот сложным, а также тем, кто хочет научится понимать код тайпингов таких библиотек как lodash.
An introductory PowerPoint to understanding and applying the C++ programming language. Broken down into lessons covering:
Introduction: Definitions and the History of Programming
Lesson 1: Libraries, Variables and Types, Blocks and Namespaces, Functions
Lesson 2: If...Else Statements, For and While Loops, Scope
Exercise: Program a Gumball Game
Lesson 3: Classes and Objects, Pointers
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxamrit47
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY GOOD WORK NICE FORMULA OR SOMETHING LIKE THAT, BUT ACTULLY HE CAN USE. THANK YOU.
Hartleys Function Code
Contains unread posts
Actions for Hartleys Function Code
Chad Hartley posted Nov 5, 2015 5:10 PM
Subscribe
This program will add an integer number and a decimal number up to 2 decimal places. I have included notes in the code to explain what each thing does. I hope I did this right. It compiles successfully.
PseudoCode
Start
Declare int O1; Stands for Output1
O1=sum; Sum is the functions name
Int sum()
Declare variables
Int num1;
Float num2;
Write “Enter a number.”
Scanf num1
Write”Enter a decimal number.”
Scanf num2
Return num1+num2
end
C Code
#include <stdio.h>
int sum();//prototype
int main()//calling program
{
//Declare a varaiable
int O1;
O1=sum();//main is calling sum one time.
//if I listed this twice it would run the function 'sum' twice.
// Example: if I add a new int (int O1, O2) and declare O2 to
//be O2=sum then the function would run twice.
}
int sum ()//function 'sum'
{
int num1;// Declare intergers/variables
float num2;
printf("Enter a number.\n");
scanf("%d",&num1);// Take first input and assign it to num1
printf("Enter a decimal number.\n");
scanf("%.2f",&num2);
//Can use the printf statement but when you are calling an integer you can use the return.
//printf("The sum of %d, %d, is %d", num1,num2,num1+num2);
return num1+num2;
}
ADD COMMENT HERE
Chaotic Function
Contains unread posts
Actions for Chaotic Function
Joshua Ray posted Nov 5, 2015 2:33 PM
Subscribe
float tmp
int i
function float chaos(float num)
{
for i < 20
num = 3.9*num*(1-num)
print num
}
main
print "Program description"
print "Request input btw 0 and 1"
tmp = input
chaos(tmp)
/*
* File: main.c
* Author: JaiEllRei
*
* Created on November 5, 2015, 2:04 PM
*/
#include <stdio.h>
#include <stdlib.h>
float chaos(float num);
int main(void)
{
float tmp;
printf("This program illustrates a choatic function. \n");
printf("Input a number between 0 and 1: ");
scanf("%f", &tmp);
chaos(tmp);
}
float chaos(float num)
{
for (int i=0; i<20; i++){
/*Chaotic Formula*/
num = 3.9 * num * (1-num);
printf("%.3f \n", num);
}
}
This program illustrates a choatic function.
Input a number between 0 and 1: .2
0.624
0.915
0.303
0.824
0.566
0.958
0.156
0.514
0.974
0.098
0.345
0.881
0.409
0.943
0.210
0.647
0.891
0.379
0.918
0.293
ADD COMMENT HERE
//MPH to KPH Conversion Function
Function KPHConv(value) as float
Set KPHConv = value*1.609344
End Function
Pseudocode for simple conversion program calling function
//Declare function
// MPH to KPH Conversion Function
Functio ...
TO UNDERSTAND about stdio.h in C.
TO LEARN ABOUT Math.h in C.
To learn about ctype.h in C.
To understand stdlib.h in c.
To learn about conio.h in c.
To learn about String.h in c.
TO LEARN ABOUT process.h in C.
MOOC e Educação Aberta - Painel @ #cbie2013Ismar Silveira
Painel de Diretrizes e Políticas de IE no Brasil, realizado no #cbie2013, em 26/11/2013, na Unicamp. Fala de @ismarfrango sobre MOOC e a Comunidade de IE. Moderador: Nizam Omar. Participantes: Mauro Pequeno, Ismar Frango, Crediné Menezes.
SBIE 2009 - Workshop de Modelos Pedagógicos para EAD
Um Sistema de Recomendação para Web 2.0 baseado en Redes Sociais de Aprendizagem e Recursos Educacionais Abertos
Pollyana Notargiacomo Mustaro
Edson Pinheiro Pimentel
Ismar Frango Silveira
Ferramentas Colaborativas da Web 2.0 Aplicadas na Educação Superior
Ismar Frango Silveira
Pollyana Notargiacomo Mustaro Edson Pinheiro Pimentel
Arnaldo R. de Aguiar Vallim Filho
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Unit 8 - Information and Communication Technology (Paper I).pdf
Paradigmas de Linguagens de Programacao - Aula #4
1. Paradigmas de Linguagens de Programação Paradigma Imperativo [Passagem de parâmetros] Aula #4 (CopyLeft)2009 - Ismar Frango ismar@mackenzie.br
2. Passagem de parâmetros Valor – C, Java... Referência – FORTRAN, C++, Pascal... Resultado (out) – Ada, C# Valor-resultado /*Copy-restore*/ (inout) – Ada, C#. Read-only – C/C++ (const) Macro - C Nome – ALGOL ... “ I write the music, produce it and the band plays within the parameters that I set.” Sting
3.
4. Valor ou referência? int h, i; void B( int* w ) { int j, k; i = 2*(*w); *w = *w+1; } void A( int* x , int* y ) { float i, j; B( &h ); } int main() { int a, b; h = 5; a = 3; b = 2; A( &a , &b ); } int* &a
5. Passagem por valor (C++) 2 1 void f(int *p) { *p = 5; p = NULL; } int main() { int x=2; int *q = &x; f(q); } x = 5 q != NULL
6. Passagem por referência (C++) 2 2 void f(int A[]) { A[0] = 5; } int main() { int B[10]; B[0] = 2; f(B); cout << B[0] << endl;} 5
7.
8.
9. Associação posicional vs. Nomeada (Ada) procedure POS_PARAM is procedure ADD_UP(X_VAL,Y_VAL,Z_VAL: INTEGER ) is begin PUT(X_VAL+Y_VAL+Z_VAL); NEW_LINE; end ADD_UP; begin end POS_PARAM ADD_UP(2,4,6); ADD_UP(X_VAL=>2, Y_VAL=>4, Z_VAL=>6); ADD_UP(Z_VAL=>6, X_VAL=>2, Y_VAL=>4); ADD_UP(2, Z_VAL=>6, Y_VAL=>4); PPA POSITIONAL PARAMETER ASSOCIATION NPA NAMED PARAMETER ASSOCIATION
10. Passagem por valor x referência (Pascal) program P; var X, Y: Integer ; procedure Swap(A, B: Integer ); var Temp: begin Temp := A; A := B; B := Temp; end ; begin readln(X, Y); Swap(X, Y); writeln(X, Y) end . valor Novas variáveis no ARI de Swap PFs VL http://stwww.weizmann.ac.il/g-cs/benari/articles/varparm.pdf
11. Passagem por valor x referência (Pascal) program P; var X, Y: Integer ; procedure Swap( var A, B: Integer ); var Temp: begin Temp := A; A := B; B := Temp; end ; begin readln(X, Y); Swap(X, Y); writeln(X, Y) end . ref aliases VL
12. Passagem por valor (Java) public class Teste{ private static void aloca(String x) { x="Hello";} public static void main(String args[]) { String b="World"; aloca(b); System.out.println(b); } } World
13. Passagem por valor (Java) public class Teste{ private static String aloca(String x,String y) { x=x+y; return x;} public static void main(String args[]) { String a="Hello, "; String b="World"; String c = aloca(a,b); System.out.println(c==a); String d="World"; String e=new String("World"); System.out.println(b==d); System.out.println(b==e); String f=e.intern(); System.out.println(b==f); } } false true false true
14. Passagem por valor (C#) void Foo (StringBuilder x) { x = null ; } ... StringBuilder y = new StringBuilder(); y.Append ( "hello" ); Foo (y); Console.WriteLine (y==null); false void Foo (StringBuilder x) { x.Append ( " World" ); } ... StringBuilder y = new StringBuilder(); y.Append ( “Hello" ); Foo (y); Console.WriteLine (y); Hello World
15. Passagem por valor (Java) String first = new String(“Hello”); String second = first; first += “World”; System.out.println(second); Hello void giveMeAString (Object y) { y = "This is a string"; } ... Object x = null; giveMeAString (x); System.out.println (x); null
16. O que ocorre aqui? public class Teste2 { public static void foo (String x) { x+=" World"; } public static void main(String []a) { String y = new String("Hello"); foo (y); System.out.println(y); } } Hello public class Teste3 { public static void foo (StringBuilder x) { x.append(" World"); } public static void main(String []a) { StringBuilder y = new StringBuilder(); y.append("Hello"); foo (y); System.out.println(y); } } Hello World
17. Passagem e Alocação Java vs. C vs. C# class Elefante { public int peso=1000; //:-( Thou shalt not do this! } public class Teste{ public static void main(String args[]) { Elefante dumbo = new Elefante(); dumbo.peso=2000; Elefante dumbinho = dumbo; dumbinho.peso=500; System.out.println(dumbo.peso); } } 500 Java
18. Passagem e Alocação Java vs. C vs. C# #include <stdio.h> typedef struct { int peso; }Elefante; int main() { Elefante *dumbo = malloc (sizeof(Elefante)); dumbo->peso=2000; Elefante *dumbinho = dumbo; dumbinho->peso=500; printf("%d",dumbo->peso); return 0; } 500 C
19. Passagem e Alocação Java vs. C vs. C# C #include <stdio.h> typedef struct { int peso; }Elefante; int main() { Elefante dumbo; dumbo.peso=2000; Elefante dumbinho = dumbo; dumbinho.peso=500; printf("%d",dumbo.peso); return 0; } 2000
20. Java vs. C vs. C# using System; public struct Elefante { public int peso; } public class testecs { public static void Main(string []a) { Elefante dumbo = new Elefante(); dumbo.peso=2000; Elefante dumbinho = dumbo; dumbinho.peso=500; Console.WriteLine (dumbo.peso); } } 2000 C#
21. Java vs. C vs. C# using System; public class Elefante { public int peso; } public class testecs { public static void Main(string []a) { Elefante dumbo = new Elefante(); dumbo.peso=2000; Elefante dumbinho = dumbo; dumbinho.peso=500; Console.WriteLine (dumbo.peso); } } 500 C#
22. Passagem por referência (C#) void Foo ( ref StringBuilder x) { x = null ; } ... StringBuilder y = new StringBuilder(); y.Append ( "hello" ); Foo ( ref y); Console.WriteLine (y== null ); using System; using System.Text; public class testecsref { public static void Foo1 ( ref Elefante x) { x.peso=1000 ;} public static void Foo2 (Elefante x) { x.peso=0 ;} public static void Main(string []a) { Elefante dumbo=new Elefante(); Foo1 ( ref dumbo); Console.WriteLine (dumbo.peso); Foo2 (dumbo); Console.WriteLine (dumbo.peso); } } public class Elefante { public int peso; } public struct Elefante { public int peso; } 1000 0 1000 1000 Qual a diferença entre passar um value object por referência e um reference object por valor? true
23. Value objects x reference objects (C#) void Foo ( ref IntHolder x) { x.i=10; } ... IntHolder y = new IntHolder(); y.i=5; Foo ( ref y); Console.WriteLine (y.i); 10 public struct IntHolder { public int i; } Value object + passagem por referência void Foo (IntHolder x) { x.i=10; } ... IntHolder y = new IntHolder(); y.i=5; Foo (y); Console.WriteLine (y.i); 5 public class IntHolder { public int i; } Reference object + passagem por valor
24. Parâmetros out (C#) void Foo ( out int x) { int a = x; // Can't read x here - it's considered unassigned // Assignment - this must happen before the method can complete normally x = 10; // The value of x can now be read: int a = x; } ... // Declare a variable but don't assign a value to it int y; // Pass it in as an output parameter, even though its value is unassigned Foo ( out y); // It's now assigned a value, so we can write it out: Console.WriteLine (y);
25. Parâmetros in, out, in out (Ada) procedure Quadratic( A, B, C: in Float; Root1, Root2: out Float); procedure Sort(V: in out Vector); with CS_IO; use CS_IO; procedure OUT_MODE_EXAMPLE is VALUE_1, VALUE_2: float; MEAN: float; procedure MEAN_VALUE (NUM_1, NUM_2: in float; NUM_3: out float) is begin NUM_3:= (NUM_1+NUM_2)/2.0; end MEAN_VALUE; begin MEAN_VALUE(VALUE_1, VALUE_2, MEAN); put("The mean is "); put(MEAN);new_line; new_line; end OUT_MODE_EXAMPLE;
26. Parâmetros in, out, in out (Ada) with CS_IO; use CS_IO; procedure IN_OUT_MODE_EXAMPLE is VALUE_1, VALUE_2: float; procedure MEAN_VALUE (NUM_1: in out float; NUM_2: in float) is begin NUM_1:= (NUM_1+NUM_2)/2.0; end MEAN_VALUE; begin get(VALUE_1);get(VALUE_2); put("BEFORE MEAN VALUE: VALUE_1 = "); put(VALUE_1);put(", VALUE_2 = ");put(VALUE_2);new_line; MEAN_VALUE(VALUE_1, VALUE_2); put("The mean is "); put(VALUE_1);new_line; put("AFTER MEAN VALUE: VALUE_1 = "); put(VALUE_1);put(", VALUE_2 = ");put(VALUE_2);new_line; end IN_OUT_MODE_EXAMPLE;
27. Parameter arrays –”params” (C#), ... (Java) void ShowNumbers ( params int [] numbers) { foreach ( int x in numbers) { Console.Write (x+ " " ); } Console.WriteLine(); } ... int [] x = {1, 2, 3}; ShowNumbers (x); ShowNumbers (4, 5); static int sum (int ... numbers) { int total = 0; for (int i = 0; i < numbers.length; i++) total += numbers [i]; return total; } C# Java
29. Parâmetros default (Ada, C++) with CS_IO; use CS_IO; procedure EXAMPLE is N1: float:= 4.2; N2: float:= 9.6; procedure MEAN_VALUE (X1: in out float; X2: in float := 6.4 ) is begin X1:= (X1+X2)/2.0; end MEAN_VALUE begin MEAN_VALUE(N1); put(N1); new_line; MEAN_VALUE(N1, N2); put(N1); new_line; end EXAMPLE; #include <iostream> using namespace std; int a = 1; int f(int a) { return a; } int g(int x = f(a)) { return x; } int h() { a = 2; { int a = 3; return g(); } } int main() { cout << h() << endl; } 2 O que é impresso aqui?
30. Parâmetros read-only (C++) class IntList { public: const Print (ostream &o); }; void f(const IntList &L) { L.Print(cout); } bool Compare(const vector <int> & A) // precondition: A is sorted { int k; for (k=1; k<A.size(); k++) { if (A[k-1] == A[k]) return true; } return false; } E se aqui não fosse const?
31. Macros #define MAXLINE 100 char line[MAXLINE]; ... getline(line, MAXLINE); #define A 2 #define B 3 #define C A + B int x = C * 2; O que acontece aqui? Por que não tem ponto-e-vírgula?
32. Pass-by-name (ALGOL) procedure double(x); real x; begin x := x * 2 end; double(C[j]) C[j] := C[j] * 2. real procedure Sum(j, lo, hi, Ej); value lo, hi; integer j, lo, hi; real Ej; begin real S; S := 0; for j := lo step 1 until hi do S := S + Ej; Sum := S end; Sum(i, 1, n, x[i]*i) Como simular isso em C++ ou Java?
33. Pass-by-name (ALGOL) procedure swap (a, b); integer a, b, temp; begin temp := a; a := b; b:= temp end; swap(x, y) temp := x; x := y; y := temp swap(i, x[i]) temp := i; i := x[i]; x[i] := temp Antes i = 2 x[2] = 5 Depois i = 5 x[2] = 5 x[5] = 2
35. /* I f *y is zero and x > 0 : set *k to biggest integer. * If *y is zero and x <=0 : leave *k unchanged. * If *y is not zero : * set *k to be x divided by *y and increment *y by 1. */ #define INT_MAX 1000 void check_divide ( int *k, int x, int *y) { if (*y = 0) if (x > 0) *k = INT_MAX; else *k = x / * y / * *y cannot be 0 */ ; *y++; } int main( ) { int a=2; check_divide(&a, a, &a); cout<<a; } 0 C++
36. /* I f *y is zero and x > 0 : set *k to biggest integer. * If *y is zero and x <=0 : leave *k unchanged. * If *y is not zero : * set *k to be x divided by *y and increment *y by 1. */ #define INT_MAX 1000 void check_divide ( int *k, int x, int *y) { if (*y == 0) { if (x > 0) *k = INT_MAX; } else { *k = x / * y / * *y cannot be 0 */ ; (*y)++;} } int main( ) { int a=2; check_divide(&a, a, &a); cout<<a; } 3 C++
37. #define TAM 10 void change ( int v[ ], int &ntx) { for (;ntx>0;ntx--) v[ntx]=ntx---1; } int main() { int k[TAM],i=0,; for (;;) { if (i==TAM) break ; k[i++]= i*2;} change(k,i); for (;;) { if (i>TAM) break ; cout<<k[i++]<<endl;} } 0 2 1 6 3 10 5 14 7 18 9 C++
38. using namespace System; double average( ... array<Int32>^ arr ) { int i = arr->GetLength(0); double answer = 0.0; for (int j = 0 ; j < i ; j++) answer += arr[j]; return answer / i; } int main() { Console::WriteLine("{0}", average( 1, 2, 3, 6 )); } Visual C++ (.NET) 3
39. void g ( int &a) { a++; } void h ( int &a) { a*=2; } void k ( int &a) { a*=10; } void f( int &number, void (*function)( int &) ) { (*function )( number ); } int main() { int select, count=0; for (select = 1; select<=3 ;select++) { switch ( select ) { case 1: f( count, g ); break ; case 2: f( count, h ); break ; case 3: f( count, k ); default: break; } } cout << count; } 20 C++
40. Pascal procedure swap(arg1, arg2: integer); var temp : integer; begin temp := arg1; arg1 := arg2; arg2 := temp; end ; ... { in some other procedure/function/program } var var1, var2 : integer; begin var1 := 1; var2 := 2; swap(var1, var2); end ; Var1=1 Var2=2
41. public class TestY { public static void differentArray(float[] x) { x = new float[100]; x[0] = 26.9f; } public static void main(String a[]) { float[ ] xx = new float[100]; xx[0] = 55.8f; differentArray(xx); System.out.println("xx[0] = " + xx[0]); } } Java 55.8
42. procedure sub1(x: int; y: int); begin x := 1; y := 2; x := 2; y := 3; end; sub1(i, a[i]); Algol a={2,3}