My code works fine on Visual Studio but when i try to submit my code to URI i get runtime error...here's the link for the problem i am trying to slove hope this helps & thx in advance http://ift.tt/1DKv8nA
#include <iostream>
using namespace std;
class LostBoots{
public:
void intSwap(int *element1, int *element2){
int temp = *element1;
*element1 = *element2;
*element2 = temp;
}
void charSwap(char *element1, char *element2){
char temp = *element1;
*element1 = *element2;
*element2 = temp;
}
void sort(int arr[], char arcr[], int length){
for (int i = 0; i < length - 1; i++){
for (int j = i + 1; j < length; j++){
if (arr[i] > arr[j]){
intSwap(&arr[i], &arr[j]);
charSwap(&arcr[i], &arcr[j]);
}
}
}
}
};
int main(){
int N, M[60], count;
char L[60];
LostBoots boot;
while (cin >> N){
count = 0;
for (int i = 0; i < N; i++){
cin >> M[i] >> L[i];
}
boot.sort(M, L, N);
for (int i = 0; i < N; i++){
if (i % 2 == 0){
if (M[i] == M[i + 1] && L[i] != L[i + 1])
count++;
}
}
cout << count << endl;
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire