Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
code jam
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <conio.h>
#define IN "A-large-practice.in"
#define OUT "A-large-practice.out"
using namespace std;
int main(int argc, char** argv) {
ifstream InFile;
ofstream OfFile;
int N, C, I, i = 0, j = 0, sumcount;
int * items;
bool mind = true;
InFile.open(IN);
OfFile.open(OUT);
if(InFile.is_open() && OfFile.is_open()) {
InFile >> N;
for(int l=0; l<N; l++) {
InFile >> C;
InFile >> I;
items = new int[I];
for(int m=0; m<I; m++) {
InFile >> items[m];
}
while((i < I) && (mind == true)) {
while((j < I) && (mind == true)) {
if((items[i] + items[j] == C) && (j != i)) {
OfFile << "Case #" << l+1 << ": " << i+1 << " " << j+1 << endl;
mind = false;
}
j++;
sumcount++;
}
j = 0;i++;
}
j = 0;i = 0;
mind = true;
delete []items;
}
OfFile << "Summe: " << sumcount << endl;
InFile.close();
OfFile.close();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment