int main()
{
	string s[50]={"7748297018","8395414567","7006199788","5446757413","2972498628",
"0508396790","9986085827","2386063041","5687189519","7729785238"};
	DiagonalDisproportion test;
	int sum =test.getDisproportion(s);
  cout<<sum;
  return 0;
}
示例#2
0
int main()
{
	DiagonalDisproportion test;

	vector<string> coll;
	coll.push_back("9000");
	coll.push_back("0120");
	coll.push_back("0000");
	coll.push_back("9000");

	cout << test.getDisproportion(coll) << endl;

	return EXIT_SUCCESS;
}
int test3() {
    vector<string> matrix = {"7748297018", "8395414567", "7006199788", "5446757413", "2972498628", "0508396790", "9986085827", "2386063041", "5687189519", "7729785238"};
    DiagonalDisproportion* pObj = new DiagonalDisproportion();
    clock_t start = clock();
    int result = pObj->getDisproportion(matrix);
    clock_t end = clock();
    delete pObj;
    int expected = -24;
    if(result == expected) {
        cout << "Test Case 3: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 3: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
int test18() {
    vector<string> matrix = {"526592379670291", "210268357618794", "076499992223892", "448020273115889", "815047433564355", "910331063665950", "311090619276722", "771847228677792", "350753582883135", "541652915679025", "719463841924512", "566960773410957", "807782715089381", "707004952710696", "272689529098809"};
    DiagonalDisproportion* pObj = new DiagonalDisproportion();
    clock_t start = clock();
    int result = pObj->getDisproportion(matrix);
    clock_t end = clock();
    delete pObj;
    int expected = -21;
    if(result == expected) {
        cout << "Test Case 18: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 18: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
int test2() {
    vector<string> matrix = {"6"};
    DiagonalDisproportion* pObj = new DiagonalDisproportion();
    clock_t start = clock();
    int result = pObj->getDisproportion(matrix);
    clock_t end = clock();
    delete pObj;
    int expected = 0;
    if(result == expected) {
        cout << "Test Case 2: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 2: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
int test17() {
    vector<string> matrix = {"61848592928287677725", "64106717459530408771", "53134608052177709007", "82996585777747770509", "73870638002515818038", "97499053552726315152", "85134698711164603379", "35999139148435239656", "25170099818793101808", "24138321584762817989", "45559388186695256747", "52177652493694657495", "94818828149976576171", "32132145980237254388", "30919247968170469869", "86395666293146553909", "23402000322199482890", "62946815706540134710", "18563312219276811905", "33108310675980226769"};
    DiagonalDisproportion* pObj = new DiagonalDisproportion();
    clock_t start = clock();
    int result = pObj->getDisproportion(matrix);
    clock_t end = clock();
    delete pObj;
    int expected = 22;
    if(result == expected) {
        cout << "Test Case 17: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 17: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
int test16() {
    vector<string> matrix = {"295721130154270278130121134", "073719109065537901009799432", "389831387245621367383452114", "272954600242617277724961790", "569909766196747971979387963", "932092216445085686334887102", "639303574798124546428453680", "451686306823984137337603303", "116945380903777003450251533", "866897040127871617202176335", "782101789719082056119847784", "228994955265100528352480070", "362924071347190704188141218", "710167623804351610774653351", "586406155657664788548043471", "516652318378140411158161360", "388991515674952395017136741", "862879557066032771059055685", "572230852855364051089855280", "619214483724292008112716847", "355124767376505615872589851", "315569633548316530738405739", "393631021591846759314087223", "595095978986475047201571707", "322009129218814736693269620", "044537348880582094074755167", "246167194666280246626974039"};
    DiagonalDisproportion* pObj = new DiagonalDisproportion();
    clock_t start = clock();
    int result = pObj->getDisproportion(matrix);
    clock_t end = clock();
    delete pObj;
    int expected = -18;
    if(result == expected) {
        cout << "Test Case 16: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 16: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
int test15() {
    vector<string> matrix = {"324373412608120582978731028250420875", "478066795093686304942023459238852935", "231003297234015601155069170746253915", "088465808469696937757599788497932194", "824895252424247296236393724654564287", "472568176220165218230635274239756705", "333766130571266138198917953344092970", "722440440262059521980699586764034012", "073075869837642222534909917636261206", "933800643255009083672454258651519001", "882170110308005291753060655160877884", "953489880860969724059385704342598074", "661620597099942494895084450077400096", "229244041296716507615803402848931474", "326746988309492616535658005780117970", "557074327251617525311473571604052344", "743879738938134514897374902736250851", "569298517134772604683366852958291546", "482055882344782841175902094717978500", "833218551600822722743115059651239588", "675142085797961714243268262405724702", "683789246902404341878179041899031067", "509880829175539235658693213766167702", "576088646809616258490031828844581419", "512825829591756574320756515197944602", "304289204691085527629667959363593035", "044353385273879212362247248328141184", "476341710304960926140956924285784740", "647630447318263640814820824504421645", "042637636407859191826631945500518807", "630605034595506482857666887996282088", "562222605604372221277324795363358687", "999667954671113905961766180040522239", "360837346988608077381830224778595545", "245041553047075191008991957144973073", "971974405673635250399609703806005525"};
    DiagonalDisproportion* pObj = new DiagonalDisproportion();
    clock_t start = clock();
    int result = pObj->getDisproportion(matrix);
    clock_t end = clock();
    delete pObj;
    int expected = -30;
    if(result == expected) {
        cout << "Test Case 15: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 15: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
int test14() {
    vector<string> matrix = {"6594008458297528627841751874682480173377634248551", "1837513818909817884717983807339108303071202821557", "9814345502678010741753559097762538464881979659953", "8031130230354170085471629253969107137391473335004", "9818349469834535410522232538627420482454928066589", "8711138032268657696503970744856458221121642669590", "9717623954876312368547395091151766728199899446167", "4479914405228592726967280568994992351355192127937", "4784007972429659301125071005806621593234601639241", "1842768883957499529652466384955357351466856706736", "0678538809279856853525896227513964247815211953733", "1150609275062586184506834847246500979194818025513", "2120892670513429965568613148219820131085020756342", "8736404109226787109533432295570830479340941189734", "5581520913705697204721334658201403432817809712494", "5007969617776592575662932641238710754093982156201", "4504341694671708940689997512243527325377648644403", "0681516866683487691837594111719717599125681435835", "5199180074220229835727560029882323709958230978882", "7210854652527949704860537416611916607725824649242", "2792541571474352980289782893164806451599131362895", "9571345703471723950178210624647702755764893481466", "4375656947588848088582531244821488600412981375522", "0894378965287139646951882078757861390212165751651", "5937583259646128206758119680848566109797464289991", "1867417525424025125092651792995831601998238159943", "0163001075484249157678987383768756423163594618856", "0073531612519710288815088904380047738503280219594", "1706503150667386315354127329080854458665781219911", "0351087153156516630507653375774904700725042878351", "8691344989632623585566501090346845695080761008746", "9165817737870998770640513331666252400257358004133", "3886068223082077037232185402513062766691193925067", "1064921810782219003030416866068587818292643800000", "9757865832679014701400742733590009499430979721779", "5378735753065664675008350352672744794466228927792", "0425641957692411617584321692441461839844205109582", "3526243266917314851179218965052060740614808773471", "0370523169571225019135872274920465318680554778287", "1235023301813123005852405966412956543225509561365", "7783820166357667217891172703399274430889276071438", "6564464112759091603279914753234338094517838843042", "4228228696291607025233185055053178513840647323650", "4786359467211913257453979646809418152959735687667", "0211782357754233647983165159052509417217215751702", "2990594762551019398398299066611466688750642518735", "7888401288394432764347411659097030147532726441649", "2819290287110554931792641576270438291050799912526", "6523768875996422197855981010140436745322463743928"};
    DiagonalDisproportion* pObj = new DiagonalDisproportion();
    clock_t start = clock();
    int result = pObj->getDisproportion(matrix);
    clock_t end = clock();
    delete pObj;
    int expected = 51;
    if(result == expected) {
        cout << "Test Case 14: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 14: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
int test7() {
    vector<string> matrix = {"88981113211000979905852233544953123951517818017499", "65014178107479438727072049431618801886976801710791", "79747856426946766665175522494969397478405133666817", "22543557816521013499713528783208274174171457152854", "53506968130718545224047785688964870071421177785816", "33132641187995254803525253350499352100453061538634", "05401204678145979968443757727737090333700393330233", "40548776796598593862497484163168520880296581889428", "04469429961782270852611129883577274529601195262236", "81271104207156577782172843481637659094711977336695", "10829656091888809134133270633086006158399822457880", "94661365579754559736540445493322932428402390665089", "71096163318255657930368094362085014413713816712072", "99358443172641275179839684314608419368132709139925", "45464293272142623014281045849712970822804166771723", "65137818814560050871864952850646294835109989937640", "87347035281678516569471528039005654282283333084301", "28064775140832452837031676290335028602369656552940", "52031199229041805160921091505927220155722469216575", "71285998600315694786363390698383703065754170645619", "32126479670636502465148408596947139111716820919435", "81657502835965538752169875605284125854915065514431", "78210665917301087349822710401047854365988541776341", "27528146866990206084437048735305771578871114382795", "82315921106796879060386948800999482775439329615253", "43079649969715415570768900857158286129495020685278", "25487899632210915800123480095226406744102864870647", "70538573634042617894332090782635473682563355613877", "93373445011270817246552735691129717408817363037790", "27726641945377358555302450601484363078711493363348", "10886804948159713323773004251211919039187979907582", "29519328172655925873190590374487826760469415914700", "35218462538162996641745688296227240402531783500000", "85664277299701601178294667656737532071143442659348", "84375116242295611616261264716236362504128647337554", "21918854276656202056471977312688153633252380319081", "94806817256685756819858624191571439283619300687025", "06501129080679100008608540094489491018057769727421", "42885065184143871935662332218216785473504746886232", "70492662060372751005200364990545909873589534036302", "58586100500086062758399063508114624175720163038899", "30428157712349250052884955540492108837906542512073", "54718606583997177018712660868807375947020391832666", "10620850738077940377416984445104491771188426426516", "89625119661318270906617454639123774577204661918891", "60102122504033028145416284501841079396768523900240", "56809751241745454348080979897716852050911926088784", "68802807042286517560246658577887532486763422646316", "20086304774825329740781807530596952660375577641206", "47665456857974363264183247009798560568852670562986"};
    DiagonalDisproportion* pObj = new DiagonalDisproportion();
    clock_t start = clock();
    int result = pObj->getDisproportion(matrix);
    clock_t end = clock();
    delete pObj;
    int expected = 7;
    if(result == expected) {
        cout << "Test Case 7: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 7: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
示例#11
0
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, vector <string> p0, bool hasAnswer, int p1) {
	cout << "Test " << testNum << ": [" << "{";
	for (int i = 0; int(p0.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << "\"" << p0[i] << "\"";
	}
	cout << "}";
	cout << "]" << endl;
	DiagonalDisproportion *obj;
	int answer;
	obj = new DiagonalDisproportion();
	clock_t startTime = clock();
	answer = obj->getDisproportion(p0);
	clock_t endTime = clock();
	delete obj;
	bool res;
	res = true;
	cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
	if (hasAnswer) {
		cout << "Desired answer:" << endl;
		cout << "\t" << p1 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = answer == p1;
	}
	if (!res) {
		cout << "DOESN'T MATCH!!!!" << endl;
	} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
		cout << "FAIL the timeout" << endl;
		res = false;
	} else if (hasAnswer) {
		cout << "Match :-)" << endl;
	} else {
		cout << "OK, but is it right?" << endl;
	}
	cout << "" << endl;
	return res;
}