1016: 幼儿园小朋友们的难题
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                1016: 幼儿园小朋友们的难题
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.                        
                                明若清溪天下絕歌 繾綣成說,不知該在哪處著墨;一生情深怎奈何世事 徒留斑駁,只一念癡戀成奢。
題目描述
?
幼兒園的小朋友們一直在研究一個(gè)問題——?如何在一個(gè)長長的句子中找到最大的那個(gè)非負(fù)整數(shù)(不存在負(fù)數(shù))。你很不幸的被他們拖住了,又很不幸的被他們叫去執(zhí)行這個(gè)任務(wù),你非常得不爽!?因?yàn)槟阌X得這么簡單的問題簡直侮辱了你的智商,所以你決定寫一個(gè)程序來代勞。
?
?
輸入
?????
輸入有多組數(shù)據(jù)。每組輸入一個(gè)句子(一定包含數(shù)字字符,可能包含空格),長度小于256,占一行
?
?
輸出
?????
輸出對應(yīng)有多行,每行輸出所找出的最大的那個(gè)非負(fù)整數(shù)
?
?
樣例輸入
復(fù)制樣例數(shù)據(jù)
&&12345aBsdDkjie64skjd5lk 3*2&&0%%%00B58CD000000b a000b0000000c000樣例輸出
12345 58 0 #include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <cstring> #include <cstdlib> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <vector> #include <ctime> #include <cctype> #include <bitset> #include <utility> #include <sstream> #include <complex> #include <iomanip> #define inf 0x3f3f3f3f typedef long long ll; using namespace std; char s[300],mx[300],tmp[300]; int main() {while(gets(s)){int cd=strlen(s),k=1;mx[0]='0';mx[1]='\0';tmp[0]='\0';for(int i=0; i<cd; i++){int j=0;if(s[i]>='1'&&s[i]<='9'){while(i<cd&&s[i]>='0'&&s[i]<='9'){tmp[j++]=s[i++];}tmp[j]='\0';if(j>strlen(mx)||(j==strlen(mx)&&strcmp(tmp,mx)>0)){for(k=0; k<j; k++)mx[k]=tmp[k];}mx[k]='\0';}}for(int i=0; i<k; i++)cout<<mx[i];cout<<endl;}return 0; }?
總結(jié)
以上是生活随笔為你收集整理的1016: 幼儿园小朋友们的难题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: HTML5文件夹隐藏了怎么打开,怎样显示
 - 下一篇: c++获取mac操作系统的版本号