Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build C++ Project

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: code compile test
uses: actions/checkout@v4

- name: Install g++
run: sudo apt-get update && sudo apt-get install -y g++

- name: Compile project
run: g++ main.cpp --std=c++17 -o MyFave

- name: Run executable (optional)
run: ./MyFave
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a.out
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# MyFave

[![Build C++ Project](https://github.com/bincent0929/vr-MyFave/actions/workflows/main.yml/badge.svg?branch=main&event=status)](https://github.com/bincent0929/vr-MyFave/actions/workflows/main.yml)

This is a simple C++ command line application to maintain a list of your favorites.

## Getting Started
Expand Down
25 changes: 15 additions & 10 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,32 @@ using std::cout, std::cin, std::endl, std::string, std::vector;

int main()
{
string input = "";
string input;
vector <string> favorites;

cout << "At any time, type DONE to stop recording favorites.\n";

do
bool first_run = true;
while (input != "DONE")
{
if( favorites.size() == 0 ){
cout << "What is your favorite?\n";
if (first_run == false) {
favorites.push_back(input);
}
else{
cout << "What is your next favorite?\n";
else {
first_run = false;
}

if( favorites.size() == 0 )
cout << "What is your favorite?\n";
else
cout << "What is your next favorite?\n";

getline(cin,input);
favorites.push_back(input);
}while( input != "DONE" );
}

cout << "Your favorite list:\n";
for(int i = 0; i < favorites.size() -1; i++){
for(int i = 0; i < favorites.size(); i++) // whole list printed
cout << favorites.at(i) << endl;
}

return 0;
}