Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // neural ntwrks.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include<iostream>
- using namespace std;
- int squash (float x,float threshold)
- {
- if( x> threshold)
- return 1;
- else return 0;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- int ch,i1,i2;
- float x;
- cout<<"Choose 1 for AND 2 for OR";
- cin>>ch;
- if(ch==1)
- { cout<<"\nEnter 2 inputs: ";
- cin>>i1>>i2;
- x=i1*.5+i2*0.5;
- cout<<"the output of the AND operation is " <<squash(x,0.8)<<"\n\n";
- system("pause");
- }
- else if(ch==2)
- { cout<<"\nEnter 2 inputs: ";
- cin>>i1>>i2;
- x=i1*.5+i2*0.5;
- cout<<"the output of the OR operation is " <<squash(x,0.1)<<"\n\n";
- system("pause");
- }
- else
- {
- cout<<"invalid ch";
- system("pause");
- }
- return 0;
- }
- /*
- Choose 1 for AND 2 for OR1
- Enter 2 inputs: 1 0
- the output of the AND operation is 0
- Press any key to continue . . .
- Choose 1 for AND 2 for OR1
- Enter 2 inputs: 1 1
- the output of the AND operation is 1
- Press any key to continue . . .
- Choose 1 for AND 2 for OR2
- Enter 2 inputs: 0 0
- the output of the OR operation is 0
- Press any key to continue . . .
- Choose 1 for AND 2 for OR2
- Enter 2 inputs: 1 0
- the output of the OR operation is 1
- Press any key to continue . . .
- */
Advertisement
Add Comment
Please, Sign In to add comment