C++作业4

来源:互联网 发布:sql删除字段不满足 编辑:程序博客网 时间:2024/06/17 01:54
1.#include<iostream.h>  void main()  {      int i,j;      for(i=1;i<12;i++)      {          for(j=1;j<12;j++)          {              if(i<=6)              {                  if(j<=(6-i)||j>=(6+i))                      cout<<" ";                  else cout<<"*";              }              else              {                  if(j<=(i-6)||j>=(18-i))                      cout<<" ";                  else cout<<"*";                 }          }          cout<<endl;      }  } 2.#include<iostream>  using namespace std;int main()  {      int a,b,c;      for(a=1;a<=9;a++)      {          for(b=1;b<=a;b++)          {              c=a*b;              cout<<b<<"x"<<a<<"="<<c<<" ";              c=1;          }          cout<<endl;      }       return 0;} 3.#include <iostream.h>   void main( )  {      int x,y,z;  cout<<"百钱百鸡问题中可以有的办法有这些:"<<endl;  for(x=0;x>=0&&x<=20;x++)  for(y=0;y>=0&&y<=33;y++)  for(z=0;z>=0&&z<=100;z++)  if(x+y+z==100&&5*x+3*y+z/3.0==100)  cout<<"鸡翁"<<x<<"只"<<","<<"鸡母"<<y<<"只"<<","<<"鸡雏"<<z<<"只"<<"。"<<endl;  } 

0 0
原创粉丝点击