fixed index
This commit is contained in:
parent
e9261771e3
commit
c23e31d3d4
|
@ -52,3 +52,8 @@
|
|||
+ Lecture (2/28/2024)
|
||||
+ https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/mistake1.cpp talking about easy to make mistakes such as accidentally mixing up = and ==
|
||||
+ https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/nestedfor.cpp nested for loops
|
||||
+ Lecture (3/6/2024)
|
||||
+ https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/palfor.cpp a simple version of palindrome finding for single words
|
||||
+ https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/arrayofarrays.cpp an examples of how an array of strings would work, this example shows how to find the acrostic of a set of sentences (well, just individual words you can change the code to use getline to make it work with whole sentences)
|
||||
+ https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/whileArray.cpp this is an example of how to traverse an array only *partially* with a while-loop rather than a for loop
|
||||
+ https://tildegit.org/left_adjoint/cs161AWinter2024/src/branch/main/palWithSpaces.cpp an example of how to solve discussion for in a single while loop
|
||||
|
|
|
@ -20,7 +20,7 @@ int main(){
|
|||
int sum = 0;
|
||||
|
||||
int j = 0;
|
||||
while(arr[j] != 0 && j < 10){
|
||||
while(j < 10 && arr[j] != 0){
|
||||
sum = sum + arr[j];
|
||||
cout << j << endl;
|
||||
j++;
|
||||
|
@ -28,4 +28,4 @@ int main(){
|
|||
|
||||
cout << "The sum was: " << sum << endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue