-
-
Save lprsd/960830 to your computer and use it in GitHub Desktop.
code jam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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