输入的一段字符串中(大小写字母是相同的)将重复出现的字符消除;
输入AaBb
输出:ab
#include <iostream> #include<string> #include<stdio.h> using namespace std; int main() { int a[100]; memset(a, 0, sizeof(a)); char num[1000]; cin >> num; int j = 0; for (int i = 0; i < strlen(num); i++) { if (num[i] >= 97&&num[i]<=122) { num[i] = num[i] - 32; } else if (a[num[i]] == 0) { a[num[i]] = 1; num[j++] = num[i]; } } num[j] = ‘\0‘; puts(num); }
原文地址:https://www.cnblogs.com/PD-yin996649850/p/12495072.html
时间: 2024-11-05 16:55:22