Skip to content

Instantly share code, notes, and snippets.

@m0hmad
Last active February 28, 2018 19:03
Show Gist options
  • Save m0hmad/caa0fa896fd02b5152fcfc7dc698b58b to your computer and use it in GitHub Desktop.
Save m0hmad/caa0fa896fd02b5152fcfc7dc698b58b to your computer and use it in GitHub Desktop.
/* chitcom:
* getMsgPrice(int *a, int *b)
* a - price
* b - messeg
*/
#include <stdio.h>
#include <string.h>
int getMsgPrice( char *a, char *b )
{
int count;
count = 0;
int j, i;
for ( i = 0; i < strlen(a); i++ ) {
if ( a[i] == -47 ) { continue; }
if ( a[i] == -48 ) { continue; }
for ( j = 0; j < strlen(b); j++ ) {
if ( b[j] == -47 ) { continue; }
if ( b[j] == -48 ) { continue; }
if ( a[i] == b[j] )
count++;
}
}
return count;
}
int main( int argc, char *argv[] )
{
if ( argc < 3 ) {
printf( "Error Input: no arguments\n" );
return 1;
}
printf( "%d\n", getMsgPrice( argv[1], argv[2] ) );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment