Aug 22, 2023 •325 likes •413 views
1. int x = 3, y = 5; 2. int* px = &x; 3. int* py = &y; 4. printf("%d %d\n", x, y); 5. *px = 10; 6. printf("%d %d\n", x, y); 7. px = py; 8. printf("%d %d\n", x, y); 9. *px = 12; 10. printf("%d %d\n", x, y);
•
• • • –
Recommend
void swap(int x, int y) { x = y; y = x; } int a = 2, b = 6; swap(a,b); void swap(int x, int y) { int temp = y; y = x; x = temp; } int a = 2, b = 6; swap(a,b); void swap(int* x, int* y) { int* temp = y; y = x; x = temp; }
526 views • 8 slides
Selection Problems int FindMax(int[] list,int low, int high){ int max = low; for(int i=low+1;i<=high; i++) if (list[i]>list[max]) max = i; return max; } What is the cost? Is this optimal? Proof of Lower Bound int FindMax(int[]
173 views • 14 slides
The heap hic 1 Limitations of the stack int *table_of(int num, int len) { int table[len+1]; for (int i=0; i <= len; i++) { table[i] = i*num; } return table; /* an int[] can be used as an int* */ } What happens if we call the function
524 views • 37 slides
void fuzz(char* buf, int& len){ void fuzz(char* buf, int& len){ void fuzz(char* buf, int& len){ void fuzz(char* buf, int& len){ void fuzz(char* buf, int& len){ int q = rand()%20; int q = rand()%20; int q = rand()%20; int
836 views • 61 slides
CSE 351: Week 4 Tom Bergan, TA 1 Does this code look okay? int binarySearch(int a[], int length, int key) { int low = 0; int high = length - 1; while (low <= high) { int mid = (low + high) / 2; int midVal = a[mid]; if (midVal < key)
444 views • 33 slides
TDDE18 & 726G77 Templates Duplicate code functions int sum(int a, int b) { return a + b; } int main() { cout << sum(1, 2) << endl; } Duplicate code functions int sum(int a, int b) { return a + b; } int main() {
416 views • 31 slides
Examples: Well-formed types These are types: int bool int * bool int * int -> int Examples: Not yet types Types in waiting dont classify terms (yet) list (but int list is a type) array (but char array is a
441 views • 26 slides
Reasoning About Code 1/25/2010 int deref(int *p) { return *p; } /* requires: p != NULL */ int deref(int *p) { return *p; } int sum(int a[], size_t n) { int total = 0; for (size_t i=0; i<n; i++) total += a[i]; return total; } /*
280 views • 24 slides
Linear Search int search(int[] list, int target, int n) { for (int i=1; i<=n; i++) if (target == list[i]) return i; return -1; } Order of growth for worst case? Lower Bound on Searching an Unordered List Prove we cant do any better
248 views • 11 slides
CSC 2400: Computer Systems Using the Stack for Function Calls Lecture Goals int add3(int a, int b, int c) { int d; How are function calls d = a + b + c; implemented at the return d; } machine level? int main() { int sum, avg;
782 views • 42 slides
Compiler Construction of Idempotent Regions and Applications in Architecture Design Marc de Kruijf Advisor: Karthikeyan Sankaralingam PhD Defense 07/20/2012 Example source code int int sum(int int *array, int int len) { int int x = 0;
1.21k views • 118 slides
Int 0 ( IntExp 5) Int 4 Gt Var x Int 4 Int 5 Int 0 ( IfExp ( GtExp ( VarExp "X") ( IntExp 4)) ( IntExp 0)) 4 + if x > 4 then 5 else 0 Plus Int 4 If Gt Var x Int 4 Int 5 Plus If Objectives What is a Grammar? Properties
67 views • 5 slides
Here be dragons Things we didnt cover in depth... int triangle(int a, int b, int c) { if (a <= 0 || b <= 0 || c <= 0) { return 4; // invalid } if (! (a + b > c && a + c > b && b + c > a)) { a > c - b a
721 views • 33 slides
Expression Evaluation Expression Value Type 4+1 5 int 30/5 6 int 30%5 0 int 05/01/10 0 int (True or False) and (not False) True bool 3000*3+1 9001 int 4%6 < 8.6/2 True bool Output of Program def myFunc(x): Output is as
513 views • 8 slides
Exercise 1 static void testMethod(int x, int y) { int a = 0; int b = 1; if((x-(2*y)) == 14) a = a + 1; if((x + (3*y)) == 9) b = b + 1; if(a == 0) System. out.println(b); } 1. Draw a CFG for this method 2. Give a minimal size test set for:
200 views • 7 slides
NOMINAL GAME SEMANTICS PART II Andrzej Murawski UNIVERSITY OF OXFORD FULL ABSTRACTION J M 1 K = J M 2 K if and only if M 1 = M 2 f int int .f (0) + 1 : ( int int ) int ( int 2 int 1 ) int 0 O 0
762 views • 49 slides
SACRIFICE: an act of surrendering the very best of yourself or something for His purpose and His glory Be willing to have the mind of Christ Be willing to forgo equality Be willing to be a servant Be willing to live in humility Be
330 views • 7 slides
ANNUAL GENERAL MEETING November 2019 REPORT OF THE COMMITTEE JEREMY A YEAR OF FUNDAMENTAL CHANGE This was our 50 th anniversary year & we celebrated it well The best day in the history of the Club (Founding member) But also a
535 views • 21 slides
Career Development of Differently-Abled Persons Annual Career Development Practitioner Congress By: MM Sefotho Emperors Palace, Gauteng Date: 24 June 2019 Disability is a global phenomenon Disabled World 2 Traditional notions of disability
569 views • 15 slides
10/4/19 Class 3a Technologies of the Self Outline Constructing Meaning in a Postmodern World Stanley Fish and arguments over what is true Constructing Meaning: From the group to the individual how each of us constructs
470 views • 5 slides
DPIs New Competitive Grant Application Application and the Tools and the Tools You can You can Use to Compete Use to Compete Federal Funding Conference March 2020 Session Session Objectives Objectives Participants will: Understand
792 views • 32 slides
COMP80122 Presentations Carole Goble | Uli Sattler School of Computer Science University of Manchester Slides are available at http://www.cs.man.ac.uk/~sattler/teaching/COMP80122/ Welcome and Basic Organisation Welcome to COMP80122
606 views • 35 slides
Practise: MUSIC teleseismic Back-Projection Multiple Signal Classification (MUSIC) q MUSICBP is a MATLAB implementation of the teleseismic MUSIC back-projections. q Open wrapper General_BP.m q Initialization (creating project folder, etc) q Read
589 views • 14 slides
Notes for Spring 2006 Below is part of an old final exam. The emphasis with this course was somewhat different, so irrelevant material was removed. Expect additional material on: 1. As described before the 6 week exam (see calendar for Feb
255 views • 12 slides
More recommend