Lecture23 - Engineering 101 Engineering 101 Lecture 23...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Engineering 101 Engineering 101 Lecture 23 Lecture 23 Vectors of Vectors Vectors of Vectors Prof. Michael Falk University of Michigan, College of Engineering Announcements Announcements Project 5 Due Tonight, 9pm New Gradebook will be posted shortly Vectors Vectors Vectors are used to store lists of things vector <int> numbers(10); int i, j; for( i=0; i < numbers.size(); i=i+1) numbers.at( i ) = i*i; for( j=0; j < numbers.size(); j=j+1) cout << numbers.at( j ) << ; cout << endl; Vectors Vectors Vectors are used to store lists of things vector <int> numbers(10); int i, j; for( i=0; i < numbers.size(); i=i+1) numbers.at( i ) = i*i; for( j=0; j < numbers.size(); j=j+1) cout << numbers.at( j ) << ; cout << endl; 1 4 9 16 25 36 49 64 81 Vectors Vectors Vectors are used to store lists of things vector <int> numbers(10); int i, j; for( i=0; i < numbers.size(); i=i+1) numbers.at( i ) = i*i; for( j=0; j < numbers.size(); j=j+1) cout << numbers.at( j ) << ; cout << endl; 1 4 9 16 25 36 49 64 81 0 1 4 9 16 25 36 49 64 81 Using Vectors to Using Vectors to Handle Text Handle Text int n; vector <string> list; string line; getline(cin, line); n = line.find( ); while(n != line.npos){ while(n==0){ line.erase(0,1); n = line.find( ); } if(line.size()!=0){ if(n == line.npos) list.push_back(line); else{ list.push_back(line.substr(0,n)); line.erase(0,n); } } n = line.find( ); } Using Vectors to Using Vectors to Handle Text Handle Text int n; vector <string> list; string line; getline(cin, line); n = line.find( ); while(n != line.npos){ while(n==0){ line.erase(0,1); n = line.find( ); } if(line.size()!=0){ if(n == line.npos) list.push_back(line); else{ list.push_back(line.substr(0,n)); line.erase(0,n); } } n = line.find( ); } empty list A line of text line ? n Using Vectors to Using Vectors to Handle Text Handle Text int n; vector <string> list; string line; getline(cin, line); n = line.find( ); while(n != line.npos){ while(n==0){ line.erase(0,1); n = line.find( ); } if(line.size()!=0){ if(n == line.npos) list.push_back(line); else{ list.push_back(line.substr(0,n)); line.erase(0,n); } } n = line.find( ); } empty list A line of text line 1 n Using Vectors to Using Vectors to Handle Text Handle Text int n; vector <string> list; string line; getline(cin, line); n = line.find( ); while(n != line.npos) { while(n==0){ line.erase(0,1); n = line.find( ); } if(line.size()!=0){ if(n == line.npos) list.push_back(line); else{ list.push_back(line.substr(0,n)); line.erase(0,n); } } n = line.find( ); } empty list A line of text line 1 n Using Vectors to Using Vectors to Handle Text Handle Text int n; vector <string> list; string line; getline(cin, line); n = line.find( ); while(n != line.npos){ while(n==0) { line.erase(0,1); n = line.find( ); } if(line.size()!=0){ if(n == line.npos) list.push_back(line); else{ list.push_back(line.substr(0,n)); line.erase(0,n); } } n = line.find( ); } empty list A line of text line 1 n Using Vectors to...
View Full Document

Page1 / 55

Lecture23 - Engineering 101 Engineering 101 Lecture 23...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online