兩道題
阿新 • • 發佈:2019-03-02
enum ber char %s for stream algo i++ continue while(cin >> List[num]){
if(List[num] == -1){
break;
}else {
num ++;
}
}
}
sort(List, List+num);
for(int i = 0; i < num; i++){
cout<<List[i];
if(i != num -1){
cout<<" ";
}
}cout<<endl;
}
} scanf("%s", List);
int num = 0;;
for(int i = 0 ;i < strlen(List); i++){
if(List[i] == ‘#‘){
continue;
}
int son = 0;
if(i *2+1 < strlen(List) && List[i * 2 + 1] != ‘#‘){
son += 1;
}
if(i *2+2 < strlen(List) && List[i * 2 + 2] != ‘#‘){
son += 1;
}
if(son == 1){
Father[num++] = List[i];
}
}
cout<<num<<":";
for(int i = 0 ;i < num; i++){
cout<<Father[i];
}
cout<<endl;
}
}
/*
1
A#B###C
*/
1、
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int List[1000];
int main(){
int CaseNumber = 0;
cin>>CaseNumber;
while(CaseNumber --){
int ListNumber = 0;
cin>>ListNumber;
int num = 0;
for(int i = 0; i < ListNumber; i++){
if(List[num] == -1){
break;
}else {
num ++;
}
}
}
sort(List, List+num);
for(int i = 0; i < num; i++){
cout<<List[i];
if(i != num -1){
}
}cout<<endl;
}
}
2、
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
char List[1000];
char Father[1000];
int main(){
int CaseNumber = 0;
cin>>CaseNumber;
while(CaseNumber --){
int num = 0;;
for(int i = 0 ;i < strlen(List); i++){
if(List[i] == ‘#‘){
continue;
}
int son = 0;
if(i *2+1 < strlen(List) && List[i * 2 + 1] != ‘#‘){
son += 1;
}
if(i *2+2 < strlen(List) && List[i * 2 + 2] != ‘#‘){
son += 1;
}
if(son == 1){
Father[num++] = List[i];
}
}
cout<<num<<":";
for(int i = 0 ;i < num; i++){
cout<<Father[i];
}
cout<<endl;
}
}
/*
1
A#B###C
*/
兩道題