Serafim_

Рисование прямоугольника и треугольника

Sep 30th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4.  
  5. {
  6. setlocale(LC_ALL, "Russian");
  7. int a,b;
  8. cout<<"Введите стороны квадрата:   ";
  9. cout<<"Длина=";
  10. cin>>a;
  11. cout<<"Ширина=";
  12. cin>>b;
  13. for(int i=1;i<=a;i++){
  14.  
  15.         for(int j=1;j<=b;j++){
  16.  
  17.                 if ((i==1)||(j==1)||(i==a)||(j==b))cout<<"#";
  18.                 else cout<<" ";
  19. }
  20.  
  21.         cout<<endl;
  22.  
  23. }
  24.  
  25.  
  26.  
  27.  
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. #include <iostream>
  40. using namespace std;
  41. int main()
  42.  
  43. {
  44.  
  45. int a,b;
  46. cout<<"Введите стороны треугольника:   ";
  47. cout<<"Длина=";
  48. cin>>a;
  49. cout<<"Ширина=";
  50. cin>>b;
  51. int r,l;
  52. for(int i=1;i<=a;i++){
  53.  
  54.         for(int j=1;j<=b;j++){
  55.             r=b/2+i;
  56.             l=b/2-i;
  57.  
  58.                 if ((j>l)&&(j<r))cout<<"*";
  59.                 else cout<<" ";
  60. }
  61.  
  62.         cout<<endl;
  63.  
  64. }
  65.  
  66.  
  67.  
  68.  
  69. }
Add Comment
Please, Sign In to add comment