#include<bits/stdc++.h> using namespace std; char fun(char s[]) { char ret=‘\0‘; if(s==NULL) return ret; char* p=s; char* q=s; while(*p!=‘\0‘) { while(*q!=‘\0‘) { ++q; if(*q==*p)break; } if(*q!=‘\0‘) { ret=*p; break; } ++p; } return ret; } char Find(char *str) { if(str == NULL || *str == ‘\0‘) return ‘\0‘; int *p = new int[256]; for(int i=0;i < 256;++i) p[i] = 0; while(*str != ‘\0‘) { p[*str]++; if(p[*str] == 2) return *str; ++str; } return ‘\0‘; } int main() { char s[]="google"; cout<<fun(s)<<endl; cout<<Find(s)<<endl; cout << "Hello,C++ world of AnycodeX!" << endl; return 0; } #include<bits/stdc++.h> using namespace std; int funadd(int n) { int tmp=n; if(n<0) tmp*=-1; int ret=tmp%10; while(tmp>10) { ret+=(tmp/10)%10; tmp/=10; } int r=ret%10; int f=ret/10; ret=f+r; if(n<0)ret*=-1; return ret; } vector<int> cs( vector<int>&unsort) { int n=unsort.size(); if(n<2) return unsort; int a[n]; int b[n]; vector<int>::const_iterator it=unsort.begin(); for(int i=0;it<unsort.end();++it,++i) { a[i]=funadd(*it); b[i]=*it; } // unsort.erase(unsort.begin(),unsort.end()); cant for(int i=0;i<n;i++) { for(int j=i;j<n;j++) if(a[j]<a[i]) { swap(a[i],a[j]); swap(b[i],b[j]); } else if(a[j] == a[i]) { if(b[j] < b[i]) { swap(a[i],a[j]); swap(b[i],b[j]); } } } for(int i=0;i<n;++i) { cout<<a[i]<<" "; } cout<<endl; for(int i=0;i<n;++i) { cout<<b[i]<<" "; } cout<<endl; vector<int> p; for(int i=0;i < n;++i) { p.push_back(b[i]); } cout<<&p<<endl; return p; } int main() { vector<int>qq; qq.push_back(17); qq.push_back(71); qq.push_back(44); vector<int> s = cs(qq); cout<<&s<<endl; vector<int>::iterator it; for(it = s.begin();it != s.end();++it) cout<<*it<<" "; cout<<endl; // qq.erase(qq.begin(),qq.end()); cout << "Hello,C++ world of AnycodeX!" << endl; return 0; } 注意上面的很多细节 10*10地板的房间 避开(5,5)地板,从(1,1)走到(10,10)有多少种最快的走法; 仅仅可以上下左右走一格; 答案: 【10!-5!*6!】 以前想过,现在再回忆。
时间: 2024-10-15 22:50:23