我试图删除字符串中元音的出现,除非它们是单词的开头.所以例如输入"The boy is about to win"
应该输出.这Th by is abt t wn
是我到目前为止所拥有的.任何帮助,将不胜感激!
def short(s):
vowels = ('a', 'e', 'i', 'o', 'u')
noVowel= s
toLower = s.lower()
for i in toLower.split():
if i[0] not in vowels:
noVowel = noVowel.replace(i, '')
return noVowel
Run Code Online (Sandbox Code Playgroud) 基本上我有两个函数,主要有一个指针指向c
(可变内存地址).我的问题是为什么我不能从print
函数调用指针并打印出字符串.另外,如果我有一个类文件并想从那里调用指针(不向print函数添加参数),该怎么办?
#include <iostream>
#include <string>
using namespace std;
static int print(){
cout << *pointer;
}
int main() {
string c = "Hello World!";
string *pointer = new string;
pointer = &c;
print();
return 0;
}
Run Code Online (Sandbox Code Playgroud)