
import re
import sys
a = str(sys.stdin.readline().strip())
if a == "":
print ("")
else:
m = re.findall("\d+",a)
maxLength = 0
if len(m) == 0:
print ("")
else :
for i in m:
# maxLength = max(maxLength,len(i))
if len(i)>= maxLength:
maxLength = len(i)
b = i
print (b+","+str(len(b)))

import sys
num1 = sys.stdin.readline().strip()
num2 = sys.stdin.readline().strip()
isNeg = False
if num1[0] == '-':
isNeg = not isNeg
num1 = num1[0]
if num2[0] == '-':
isNeg = not isNeg
num2 = num2[0]
prefix = ''
if isNeg:
prefix = '-'
product = [0] * (len(num1) + len(num2))
pos = len(product)-1
for n1 in reversed(num1):
tempPos = pos
for n2 in reversed(num2):
product[tempPos] += int(n1) * int(n2)
product[tempPos-1] += product[tempPos]/10
product[tempPos] %= 10
tempPos -= 1
pos -= 1
pt = 0
while pt < len(product)-1 and product[pt] == 0:
pt += 1
return prefix+"".join(map(str, product[pt:]))
http://blog.csdn.net/xy010902100449/article/details/50562444
#include <vector>
#include <iostream>
#include <string>
using namespace std;
typedef struct {
unsigned int uiElementLength;
unsigned int uiElementValue;
}ELEMENT_STRU;
void Decode(unsigned int uiIutputLen, unsigned char aInputByte[],
unsigned int uiElementNum, ELEMENT_STRU astElement[])
{
if (!aInputByte || !astElement)
return;
if (uiElementNum == 0 || uiIutputLen == 0)
return;
vector<int> vec;
unsigned int i = 0;
unsigned int temp = 0;
int temp1 = 0x80;
unsigned int j = 0, k = 0;
int sum = 0;
int bittemp = 0;
for (i = 0; i<uiIutputLen; i++) {
temp = aInputByte[i];
for (j = 0; j<8; j++) {
bittemp = (temp&temp1);
bittemp = (bittemp >> 7);
vec.push_back(bittemp);
temp = (temp << 1);
}
}
int size = vec.size();
for (i = 0; i<uiElementNum; i++) {
temp = 0;
for (j = 0; j<astElement[i].uiElementLength; j++) {
if (astElement[i].uiElementLength<1 && \
astElement[i].uiElementLength>31)
return;
if (k>size) {
break;
}
temp = (temp << 1) + vec[k];
k++;
}
if (k>size&&temp != 0) {
astElement[i].uiElementValue = temp;
break;
}
else if (k>size&&temp == 0) {
break;
}
astElement[i].uiElementValue = temp;
}
return;
}
int main() {
int n, n1;
cin >> n;
unsigned char *inputchar = (unsigned char*)malloc(n);
for (int i = 0; i < n; i++) {
string s;
cin >> s;
inputchar[i] = (s[2] - '0') * 16 + s[3] - '0';
}
cin >> n1;
ELEMENT_STRU *astElement = (ELEMENT_STRU*)malloc(n1 * sizeof(ELEMENT_STRU));
for (int i = 0; i < n1; i++) {
cin >> astElement[i].uiElementLength;
}
Decode(n, inputchar,
n1, astElement);
for (int i = 0; i < n1; i++) {
cout << astElement[i].uiElementValue << endl;
}
return 0;
}
网友评论