The_fisher @ 2023-08-13 13:12:07
本蒟蒻70分
#include <bits/stdc++.h>
using namespace std;
char str[11];
bool un = false;
main() {
gets(str);
if (str[0] == '-') {
un = true;
}
int len = strlen(str);
if (un) {
cout << "-";
}
while (len--) {
if (str[len] == '0' || str[len] == '-') {
continue;
}
cout << str[len];
}
}
by __xux__ @ 2023-08-13 13:24:56
@zhaoyuhang1231 代码都没给完整
by Max6700 @ 2023-08-13 13:26:38
@cool_xu ?
by keinog @ 2023-08-13 13:28:02
@zhaoyuhang1231
by Max6700 @ 2023-08-13 13:28:08
@zhaoyuhang1231 特判0
if(s1[0]=='0')cout<<0;
by Max6700 @ 2023-08-13 13:28:28
@keinog 图炸了
by keinog @ 2023-08-13 13:28:43
@zhaoyuhang1231 而且你的代码不太完整
by Max6700 @ 2023-08-13 13:29:06
@zhaoyuhang1231 确实这边建议用string
,直接cin
by __xux__ @ 2023-08-13 13:29:13
@zhaoyuhang1231
中间如果有零不能删除的
#include <bits/stdc++.h>
using namespace std;
char str[11];
bool un = false,unzero;
int main() {
gets(str);
if (str[0] == '-') {
un = true;
}
int len = strlen(str);
if (un) {
cout << "-";
}
while (len--) {
if (str[len] == '0' && unzero==false || str[len] == '-') {
continue;
}else{
unzero=true;
}cout << str[len];
}
}
by keinog @ 2023-08-13 13:29:26
@Max6700 我这里图没有炸a
by __xux__ @ 2023-08-13 13:30:09
C++11的main前居然不需要int?