• Nov 18, 2022 •AustinLeath
0 likes • 0 views
#include <iostream> #include <fstream> #include <string> #include <cstring> using namespace std; //This program makes a new text file that contains all combinations of two letters. // aa, ab, ..., zy, zz int main(){ string filename = "two_letters.txt"; ofstream outFile; outFile.open(filename.c_str()); if(!outFile.is_open()){ cout << "Something's wrong. Closing..." << endl; return 0; } for(char first = 'a'; first <= 'z'; first++){ for(char second = 'a'; second <= 'z'; second++){ outFile << first << second << " "; } outFile << endl; } return 0; }
#include <iostream> #include <cmath> #include <string.h> using namespace std; int main() { string tickerName; int numOfContracts; float currentOptionValue; cout << "Enter a stock ticker: "; getline(cin, tickerName); cout << "Enter the current number of " << tickerName << " contracts you are holding: "; cin >> numOfContracts; cout << "Enter the current price of the option: "; cin >> currentOptionValue; cout << "The value of your " << tickerName << " options are: $" << (currentOptionValue * 100.00) * (numOfContracts); cout << endl; return 0; }
0 likes • 15 views
#include<iostream> using namespace std; const int rows = 8; const int cols = 8; char chessboard[rows][cols]; void setBoard(char chessboard[][cols]); void printBoard(char chessboard[][cols]); void setBoard(char chessboard[][cols]) { for(int i = 0; i < rows; i++) { for(int j = 0; j < cols; j++) { if(i % 2 == 0 && j % 2 == 0) { chessboard[i][j] = 'x'; } else { if(i % 2 != 0 && j % 2 == 1) { chessboard[i][j] = 'x'; } else { chessboard[i][j] = '-'; } } } } return; } void printBoard(char chessboard[][cols]) { for(int i = 0; i < rows; i++) { for(int j = 0; j < cols; j++) { cout << chessboard[i][j] << " "; } cout << endl; } return; } int main(int argc, char const *argv[]) { setBoard(chessboard); printBoard(chessboard); return 0; }
• Sep 3, 2023 •AustinLeath
0 likes • 10 views
#include "stdio.h" #include <stdlib.h> int main (int argCount, char** args) { int a = atoi(args[1]); int b = atoi(args[2]); unsigned int sum = 0; unsigned int p = 1; for (unsigned int i = 1; i < b; i++) { p = p * i; } // (b!, (1 + b)!, (2 + b)!, ..., (n + b)!) for (unsigned int i = 0; i < a; i++) { p = p * (i + b); sum = sum + p; } printf("y: %u\n", sum); return 0; }
• Jul 30, 2023 •LeifMessinger
1 like • 5 views
//Constant prefix notation solver using bruh //Could make it infix or postfix later #include<string> #include<vector> #include<iostream> std::vector<long double> bruhBuff; long double operator ""bruh(long double a){ bruhBuff.push_back(a); return a; } long double operator ""bruh(const char op){ if(bruhBuff.size() < 2) throw "Bruh weak"; long double b = bruhBuff.back(); bruhBuff.pop_back(); long double a = bruhBuff.back(); bruhBuff.pop_back(); switch(op){ case (int)('+'): return a + b; case (int)('-'): return a - b; case (int)('*'): return a * b; case (int)('/'): return a / b; } return 69l; } int main(){ 1.0bruh; 2.0bruh; std::cout << '+'bruh << std::endl; return 0; }
• Jun 17, 2024 •oceantran27
0 likes • 3 views
#include <iostream> using namespace std; int main { cout << 1; }