#include <stdio.h>
#include <stdlib.h>
#include "tested_declarations.h"
#include "rdebug.h"
int add(const int *first, const int *second, int* result)
{
if(first == NULL || second == NULL)
return 1;
*result=*first+*second;
return 0;
}
int subtract(const int *first, const int *second, int* result)
{
if(first == NULL || second == NULL)
return 1;
*result=*first+*second;
return 0;
}
int multiply(const int *first, const int *second, int* result)
{
if(first == NULL || second == NULL)
return 1;
*result=*first+*second;
return 0;
}
int divide(const int *first, const int *second, float* result)
{
if(first == NULL || second == NULL || second==0)
return 1;
else
{
*result=(*first)/(*second);
return 0;
}
}
int main()
{
int a,b,result;
int *pa,*pb,*pc;
pa=&a,pb=&b,pc=&result;
char *znak;
char kurwa;
znak=&kurwa;
printf("Podaj dzialanie:");
if(scanf("%d",pa)==1)
{
scanf("%c",znak);
if(scanf("%d",pb)==1)
{
if(*znak=='+')
{
if(add(pa,pb,pc)==0)
printf("%d",*pc);
else
{
printf("Operation not permitted");
return 4;
}
}
else if(*znak=='-')
{
if(subtract(pa,pb,pc)==0) printf("%d",*pc);
else
{
printf("Operation not permitted");
return 4;
}
}
else if(*znak=='*')
{
if(multiply(pa,pb,pc)==0) printf("%d",*pc);
else
{
printf("Operation not permitted");
return 4;
}
}
else if(*znak=='/')
{
if(divide(pa,pb,pc)==0)
printf("%d",*pc);
else
{
printf("Operation not permitted");
return 4;
}
}
}
else
{
printf("Incorrect input");
return 1;
}
}
else
{
printf("Incorrect input");
return 1;
}
return 0;
}
#include <stdlib.h>
#include "tested_declarations.h"
#include "rdebug.h"
int add(const int *first, const int *second, int* result)
{
if(first == NULL || second == NULL)
return 1;
*result=*first+*second;
return 0;
}
int subtract(const int *first, const int *second, int* result)
{
if(first == NULL || second == NULL)
return 1;
*result=*first+*second;
return 0;
}
int multiply(const int *first, const int *second, int* result)
{
if(first == NULL || second == NULL)
return 1;
*result=*first+*second;
return 0;
}
int divide(const int *first, const int *second, float* result)
{
if(first == NULL || second == NULL || second==0)
return 1;
else
{
*result=(*first)/(*second);
return 0;
}
}
int main()
{
int a,b,result;
int *pa,*pb,*pc;
pa=&a,pb=&b,pc=&result;
char *znak;
char kurwa;
znak=&kurwa;
printf("Podaj dzialanie:");
if(scanf("%d",pa)==1)
{
scanf("%c",znak);
if(scanf("%d",pb)==1)
{
if(*znak=='+')
{
if(add(pa,pb,pc)==0)
printf("%d",*pc);
else
{
printf("Operation not permitted");
return 4;
}
}
else if(*znak=='-')
{
if(subtract(pa,pb,pc)==0) printf("%d",*pc);
else
{
printf("Operation not permitted");
return 4;
}
}
else if(*znak=='*')
{
if(multiply(pa,pb,pc)==0) printf("%d",*pc);
else
{
printf("Operation not permitted");
return 4;
}
}
else if(*znak=='/')
{
if(divide(pa,pb,pc)==0)
printf("%d",*pc);
else
{
printf("Operation not permitted");
return 4;
}
}
}
else
{
printf("Incorrect input");
return 1;
}
}
else
{
printf("Incorrect input");
return 1;
}
return 0;
}