大佬救命
#include<iostream>using namespace std;
int countupper(char array){
int num = 0;
char uppercase;
for(int a = 0 ; a < 26 ; a++ ){
uppercase = char( 65 + a );
}
for(int i = 0; i < 6; i++){
for(int j = 0; j < 26 ; j++){
if (uppercase == array){
num = num + 1;
}
}
}
return num;
}
int main(){
char array;
cin >> array;
int num = countupper(array);
cout << num <<" uppercase characters." << endl;
return 0;
}
for(int i = 0; i < 6; i++){
for(int j = 0; j < 26 ; j++){
if (uppercase == array){
num = num + 1;
}
}
}
为什么这个if语句不会执行??
cin >> array;
#include<iostream>
using namespace std;
int countupper(char array[]) {
int num = 0;
char uppercase;
for(int a = 0 ; a < 26 ; a++ ) {
uppercase = char( 65 + a );
}
for(int i = 0; i < 6; i++) {
for(int j = 0; j < 26 ; j++) {
if (uppercase == array) {
num = num + 1;
}
}
}
return num;
}
int main() {
char array;
cin >> array;
int num = countupper(array);
cout << num <<" uppercase characters." << endl;
return 0;
}
页:
[1]