求大神帮忙,说说思路也可以~(^0^)/
2个回答
展开全部
1
=================================================
#include <iostream>
int main() {
std::cout<<"Please input some chars:";
std::string s1;
std::string s2;
std::cin >> s1;
char* strs = const_cast<char*>(s1.c_str());
while(*strs != '\0') {
if(*strs <= 'z' && *strs >= 'a'){
s2.append(1,*strs);
}
++strs;
}
std::cout << s2;
}
===============================================
2
===============================================
#include <cstdio>
using namespace std;
int main() {
float grade[][2] = { {90,78}, {88,80}, {79,76} };
float avg_s[3] = {0,0,0};
float avg_k[2] = {0,0};
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 2; ++j){
avg_s[i] += *(*(grade + i) + j);
avg_k[j] += *(*(grade + i) + j);
}
}
for(int i = 0; i < 3; ++i) {
printf("student %d avg:%.2f\n", i, avg_s[i] / 2);
}
for(int i = 0; i < 2; ++i) {
printf("ke %d avg:%.2f\n", i, avg_k[i] / 3);
}
}
=================================================
#include <iostream>
int main() {
std::cout<<"Please input some chars:";
std::string s1;
std::string s2;
std::cin >> s1;
char* strs = const_cast<char*>(s1.c_str());
while(*strs != '\0') {
if(*strs <= 'z' && *strs >= 'a'){
s2.append(1,*strs);
}
++strs;
}
std::cout << s2;
}
===============================================
2
===============================================
#include <cstdio>
using namespace std;
int main() {
float grade[][2] = { {90,78}, {88,80}, {79,76} };
float avg_s[3] = {0,0,0};
float avg_k[2] = {0,0};
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 2; ++j){
avg_s[i] += *(*(grade + i) + j);
avg_k[j] += *(*(grade + i) + j);
}
}
for(int i = 0; i < 3; ++i) {
printf("student %d avg:%.2f\n", i, avg_s[i] / 2);
}
for(int i = 0; i < 2; ++i) {
printf("ke %d avg:%.2f\n", i, avg_k[i] / 3);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询