- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
#include <iostream>
#include <string.h>
using namespace std;
int strsearch(char* from, char* what);
int getnumberafter(char* from, char* what);
int strch(char* a, char* b, int pos);
int strsearch(char* from, char* what)
{
int n=strlen(from)-strlen(what)+1;
int i;
for(i=0; i<n; i++)
if(strch(from, what, i)==strlen(what)) return i;
return 0;
}
int getnumberafter(char* from, char* what)
{
int p, ret=0;
if((p=strsearch(from,what))==0) return 0;
p+=strlen(what);
while(from[p]<'0'&&from[p]>'9')
{
p++;
if(p>=strlen(from)) return 0;
}
while(from[p]>='0'&&from[p]<='9'&&p<strlen(from))
{
ret=ret*10+(from[p++]-'0');
}
return ret;
}
int strch(char* a, char* b, int pos)
{
int i,n=min(strlen(a)-pos,strlen(b));
for(i=0; i<n; i++)
if(a[i+pos]!=b[i]) return i;
return i;
}
int main(int argc, char* argv[])
{
int i;
double max=1,vol=0;
for(i=0; i<argc; i++)
{
cout << i << ": " << argv[i] << endl;
if(strch(argv[i],"type",0)==4) { max=getnumberafter(argv[i],"max=");}
if(strch(argv[i],"values",0)==6) { vol=(getnumberafter(argv[i],"=")+getnumberafter(argv[i],","))/2;}
}
cout << vol/max << endl;
return 0;
}
HyperGeek 08.06.2010 18:39 # −1
TarasB 08.06.2010 19:06 # +2
xaionaro 09.06.2010 08:14 # +2
Говногость 08.06.2010 20:32 # 0
legolegs 08.06.2010 21:16 # 0
xaionaro 09.06.2010 08:17 # −1
legolegs 09.06.2010 18:29 # 0
xaionaro 10.06.2010 02:50 # +1
legolegs 10.06.2010 16:51 # 0
nil 10.06.2010 23:52 # 0
legolegs 11.06.2010 02:28 # 0
nil 11.06.2010 07:57 # +1
Еще вариант, кое-где использовавшийся, «отвечает».
nil 09.06.2010 10:04 # 0
gpr 09.06.2010 20:19 # +2