0
The Spy Life in C
■□■FIXED■□■ Thank youuu♡ /* For some reason my code doesn't pass the 3 and 5 test, Any idea why is that? Thanks */ #include <stdio.h> #include <string.h> #include <ctype.h> int main() { char* s =NULL; size_t size = 0; getline(&s,&size,stdin); size_t len = strlen(s); char a[len+1]; int j = 0; for(int i=len; s[len-i]!= '\0';i--) { char c=s[i-1]; if(isalpha(c) || isspace(c)) { a[j]= c; j++; } } a[j] = '\0'; printf("%s",a); return 0; }
3 Respuestas
+ 1
It doesn't work because I have to get rid of \n and \0 I think
0
#include <iostream>
using namespace std;
int main() {
string abc = "abcdefghijklmnopqrstuvwxyz ",s = "6s1o2c3a4t5",rs;
bool k = 1;
getline(cin, s);
for (int j=s.size()-1;j>=0;j--){
if(isupper(s[j])){
s[j]=tolower(s[j]);
k=0;
}
for (long unsigned int i=0;i<abc.size();i++)
{
if (abc[i]==s[j]){
if(k==0){
s[j]=toupper(s[j]);
}
rs = rs+s[j];
k=1;
break;
}
}
}
cout<<rs;
return 0;
}
This is in c++ , you can remake to C )
0
Roby Just do 2 change
s[len - (i + 2)] to s[len - (i + 1)]
and a[len + 1] to a[len]