upsidedown

Neural networks

Aug 29th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. // neural ntwrks.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include<iostream>
  6. using namespace std;
  7.  
  8.  
  9. int squash (float x,float  threshold)
  10. {
  11.     if( x> threshold)
  12.         return 1;
  13.     else return 0;
  14. }
  15.  
  16.  
  17.  
  18. int _tmain(int argc, _TCHAR* argv[])
  19. {
  20.     int ch,i1,i2;
  21.     float x;
  22.     cout<<"Choose 1 for AND 2 for OR";
  23.     cin>>ch;
  24.     if(ch==1)
  25.     {   cout<<"\nEnter 2 inputs:  ";
  26.       cin>>i1>>i2;
  27.       x=i1*.5+i2*0.5;
  28.      cout<<"the output of the AND operation is  " <<squash(x,0.8)<<"\n\n";
  29.      system("pause");
  30.     }
  31.  
  32.     else if(ch==2)
  33.     {   cout<<"\nEnter 2 inputs:  ";
  34.       cin>>i1>>i2;
  35.       x=i1*.5+i2*0.5;
  36.      cout<<"the output of the OR operation is  " <<squash(x,0.1)<<"\n\n";
  37.      system("pause");
  38.     }
  39.  
  40.     else
  41.         {
  42.             cout<<"invalid ch";
  43.             system("pause");
  44.     }
  45.     return 0;
  46. }
  47.  
  48.    
  49.  
  50.  
  51. /*
  52. Choose 1 for AND 2 for OR1
  53.  
  54. Enter 2 inputs:  1 0
  55. the output of the AND operation is  0
  56.  
  57. Press any key to continue . . .
  58.  
  59.  
  60.  
  61.  
  62. Choose 1 for AND 2 for OR1
  63.  
  64. Enter 2 inputs:  1 1
  65. the output of the AND operation is  1
  66.  
  67. Press any key to continue . . .
  68.  
  69.  
  70.  
  71.  
  72.  
  73. Choose 1 for AND 2 for OR2
  74.  
  75. Enter 2 inputs:  0 0
  76. the output of the OR operation is  0
  77.  
  78. Press any key to continue . . .
  79.  
  80.  
  81.  
  82.  
  83. Choose 1 for AND 2 for OR2
  84.  
  85. Enter 2 inputs:  1 0
  86. the output of the OR operation is  1
  87.  
  88. Press any key to continue . . .
  89.  
  90.  
  91.  
  92. */
Advertisement
Add Comment
Please, Sign In to add comment