#include <iostream>
using namespace std;
int cdefgab[8][10] ={
0,1,1,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,0,0,
0,1,1,1,0,0,1,1,1,1,
0,1,1,1,0,0,1,1,1,0,
0,1,1,1,0,0,1,1,0,0,
0,1,1,1,0,0,1,0,0,0,
0,1,1,1,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
};
int CDEFGAB[7][10]={
1,1,1,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,0,
1,1,1,1,0,0,1,1,1,0,
1,1,1,1,0,0,1,1,0,0,
1,1,1,1,0,0,1,0,0,0,
1,1,1,1,0,0,0,0,0,0,
};
int main(){
int t = 0 ;
int finger[10] = {0};
int *p, *lastp = cdefgab[7];
cin >> t;
while(t--){
for(int i = 0 ; i < 10 ;i++){
finger[i] = 0;
}
string song = "";
cin >> song ;
for(int i = 0 ; i < song.length() ; i++){
if(song[i] >= 'a' && song[i] <= 'g'){
p = cdefgab[song[i] - 'a'];
}
else if(song[i] >= 'A' && song[i] <= 'G'){
p = CDEFGAB[song[i] - 'A'];
}
for(int j = 0 ; j < 10 ; j++){
if(p[j] == 1 && ( lastp[j] == 0 || i == 0 )){
finger[j]++;
}
}
lastp = p;
}
for(int i = 0 ; i < 10 ; i++){
cout << finger[i] << " ";
}
cout << endl;
}
}
#include
using namespace std;
int cdefgab[8][10] ={
0,1,1,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,0,0,
0,1,1,1,0,0,1,1,1,1,
0,1,1,1,0,0,1,1,1,0,
0,1,1,1,0,0,1,1,0,0,
0,1,1,1,0,0,1,0,0,0,
0,1,1,1,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
};
int CDEFGAB[7][10]={
1,1,1,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,0,
1,1,1,1,0,0,1,1,1,0,
1,1,1,1,0,0,1,1,0,0,
1,1,1,1,0,0,1,0,0,0,
1,1,1,1,0,0,0,0,0,0,
};
int main(){
int t = 0 ;
int finger[10] = {0};
int *p, *lastp = cdefgab[7];
cin >> t;
while(t--){
for(int i = 0 ; i < 10 ;i++){
finger[i] = 0;
}
string song = "";
cin >> song ;
for(int i = 0 ; i < song.length() ; i++){
if(song[i] >= 'a' && song[i] <= 'g'){
p = cdefgab[song[i] - 'a'];
}
else if(song[i] >= 'A' && song[i] <= 'G'){
p = CDEFGAB[song[i] - 'A'];
}
for(int j = 0 ; j < 10 ; j++){
if(p[j] == 1 && ( lastp[j] == 0 || i == 0 )){
finger[j]++;
}
}
lastp = p;
}
for(int i = 0 ; i < 10 ; i++){
cout << finger[i] << " ";
}
cout << endl;
}
}
請問是不是有什麼小細節沒有考慮到~?
#include
using namespace std;
int cdefgab[8][10] ={
0,1,1,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,0,0,
0,1,1,1,0,0,1,1,1,1,
0,1,1,1,0,0,1,1,1,0,
0,1,1,1,0,0,1,1,0,0,
0,1,1,1,0,0,1,0,0,0,
0,1,1,1,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
};
int CDEFGAB[7][10]={
1,1,1,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,0,
1,1,1,1,0,0,1,1,1,0,
1,1,1,1,0,0,1,1,0,0,
1,1,1,1,0,0,1,0,0,0,
1,1,1,1,0,0,0,0,0,0,
};
int main(){
int t = 0 ;
int finger[10] = {0};
int *p, *lastp = cdefgab[7];
cin >> t;
while(t--){
for(int i = 0 ; i < 10 ;i++){
finger[i] = 0;
}
string song = "";
cin >> song ;
for(int i = 0 ; i < song.length() ; i++){
if(song[i] >= 'a' && song[i] <= 'g'){
p = cdefgab[song[i] - 'a'];
}
else if(song[i] >= 'A' && song[i] <= 'G'){
p = CDEFGAB[song[i] - 'A'];
}
for(int j = 0 ; j < 10 ; j++){
if(p[j] == 1 && ( lastp[j] == 0 || i == 0 )){
finger[j]++;
}
}
lastp = p;
}
for(int i = 0 ; i < 10 ; i++){
cout << finger[i] << " ";
}
cout << endl;
}
}
請問是不是有什麼小細節沒有考慮到~?
有空白行
可以改成getline,或乾脆點string拿掉改成scanf也可以
#include
using namespace std;
int cdefgab[8][10] ={
0,1,1,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,0,0,
0,1,1,1,0,0,1,1,1,1,
0,1,1,1,0,0,1,1,1,0,
0,1,1,1,0,0,1,1,0,0,
0,1,1,1,0,0,1,0,0,0,
0,1,1,1,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
};
int CDEFGAB[7][10]={
1,1,1,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,0,
1,1,1,1,0,0,1,1,1,0,
1,1,1,1,0,0,1,1,0,0,
1,1,1,1,0,0,1,0,0,0,
1,1,1,1,0,0,0,0,0,0,
};
int main(){
int t = 0 ;
int finger[10] = {0};
int *p, *lastp = cdefgab[7];
cin >> t;
while(t--){
for(int i = 0 ; i < 10 ;i++){
finger[i] = 0;
}
string song = "";
cin >> song ;
for(int i = 0 ; i < song.length() ; i++){
if(song[i] >= 'a' && song[i] <= 'g'){
p = cdefgab[song[i] - 'a'];
}
else if(song[i] >= 'A' && song[i] <= 'G'){
p = CDEFGAB[song[i] - 'A'];
}
for(int j = 0 ; j < 10 ; j++){
if(p[j] == 1 && ( lastp[j] == 0 || i == 0 )){
finger[j]++;
}
}
lastp = p;
}
for(int i = 0 ; i < 10 ; i++){
cout << finger[i] << " ";
}
cout << endl;
}
}
請問是不是有什麼小細節沒有考慮到~?
有空白行可以改成getline,或乾脆點string拿掉改成scanf也可以
簡單
#include
using namespace std;
int cdefgab[8][10] ={
0,1,1,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,0,0,
0,1,1,1,0,0,1,1,1,1,
0,1,1,1,0,0,1,1,1,0,
0,1,1,1,0,0,1,1,0,0,
0,1,1,1,0,0,1,0,0,0,
0,1,1,1,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
};
int CDEFGAB[7][10]={
1,1,1,0,0,0,0,0,0,0,
1,1,0,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,0,
1,1,1,1,0,0,1,1,1,0,
1,1,1,1,0,0,1,1,0,0,
1,1,1,1,0,0,1,0,0,0,
1,1,1,1,0,0,0,0,0,0,
};
int main(){
int t = 0 ;
int finger[10] = {0};
int *p, *lastp = cdefgab[7];
cin >> t;
while(t--){
for(int i = 0 ; i < 10 ;i++){
finger[i] = 0;
}
string song = "";
cin >> song ;
for(int i = 0 ; i < song.length() ; i++){
if(song[i] >= 'a' && song[i] <= 'g'){
p = cdefgab[song[i] - 'a'];
}
else if(song[i] >= 'A' && song[i] <= 'G'){
p = CDEFGAB[song[i] - 'A'];
}
for(int j = 0 ; j < 10 ; j++){
if(p[j] == 1 && ( lastp[j] == 0 || i == 0 )){
finger[j]++;
}
}
lastp = p;
}
for(int i = 0 ; i < 10 ; i++){
cout << finger[i] << " ";
}
cout << endl;
}
}
請問是不是有什麼小細節沒有考慮到~?
有空白行可以改成getline,或乾脆點string拿掉改成scanf也可以
簡單
請問這跟空白行有什麼關西@@
我用uva原文測資是對的