- 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;
}