#include <iostream>
#include <string>
using namespace std;
int main() {
int testy, l_miast, suma, *wyjscie;
string ciag;
cin >> testy;
//testy = 3;
wyjscie = new int [testy];
for (int i=0; i<testy; i++){
cin >> l_miast;
cin >> ciag;
//l_miast = 4;
//ciag = "0000";
suma = 0;
for (int j=0; j<l_miast; j++){
if (static_cast<int>(ciag[j])==int('1')) suma ++;
}
wyjscie[i] = 0;
if (suma>0) {
wyjscie[i] = l_miast-suma;
}
}
for (int i=0; i<testy; i++){
cout << wyjscie[i] << endl;
}
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <iostream> #include <string> using namespace std; int main() { int testy, l_miast, suma, *wyjscie; string ciag; cin >> testy; //testy = 3; wyjscie = new int [testy]; for (int i=0; i<testy; i++){ cin >> l_miast; cin >> ciag; //l_miast = 4; //ciag = "0000"; suma = 0; for (int j=0; j<l_miast; j++){ if (static_cast<int>(ciag[j])==int('1')) suma ++; } wyjscie[i] = 0; if (suma>0) { wyjscie[i] = l_miast-suma; } } for (int i=0; i<testy; i++){ cout << wyjscie[i] << endl; } return 0; } |
English