Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 24th, 2012  |  syntax: C#  |  size: 1.29 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             double x, y=0;                                
  13.             string str;                                  
  14.             char rep=' ';                              
  15.  
  16.             do                                        
  17.             {   Console.Clear();                      
  18.    
  19.                 Console.Write("введите значение x: ");
  20.                 str=Console.ReadLine();                
  21.                 x=double.Parse(str);                  
  22.  
  23.                 if (x<=-2|| x>=2)                    
  24.                     y=0;                              
  25.                 if(x<=1 && x>=-1) y=-1;              
  26.                 if (x>1 && x<2) y=x-2;                
  27.                 if (x<-1 && x >-2) y=-x-2;            
  28.  
  29.                 Console.Write("значение x="+x.ToString());
  30.                 Console.Write("значение y="+y.ToString()); y
  31.                 Console.Write("для повотора нажать y");
  32.                 rep=char.Parse(Console.ReadLine());}  
  33.             while(rep=='Y'||rep=='y');      
  34.                    }
  35.     }
  36. }