鱼C论坛

 找回密码
 立即注册
楼主: 向往青莲

[技术交流] #鱼C五周年嘉年华#《C趣味》--第一发

[复制链接]
发表于 2015-1-28 00:13:11 | 显示全部楼层

回帖奖励 +5 鱼币

热烈庆祝鱼C五周年嘉年华!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-1-28 08:31:02 | 显示全部楼层
回帖挣鱼币
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-1-28 10:28:52 | 显示全部楼层

回帖奖励 +5 鱼币

我来试一下
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-1-28 10:36:12 | 显示全部楼层

回帖奖励 +5 鱼币

我也来xuexile
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-1-28 12:59:03 | 显示全部楼层
我来啦
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-1-29 21:53:07 | 显示全部楼层

回帖奖励 +5 鱼币

  好久没有来了  今天来玩玩
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-1-29 22:35:19 | 显示全部楼层
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;

  4. int main()
  5. {
  6.         cout<<"*****"<<setw(5)<<"**"<<setw(7)<<"***"<<setw(5)<<"*"<<setw(14)<<"*****"<<endl;
  7.         cout<<"*"<<setw(13)<<"*"<<setw(8)<<"*"<<setw(9)<<"*"<<endl;
  8.         cout<<"*****"<<setw(5)<<"**"<<setw(5)<<"*"<<setw(11)<<"*****"<<setw(5)<<"*"<<endl;
  9.         cout<<"*"<<setw(9)<<"**"<<setw(9)<<"*"<<setw(3)<<"*"<<setw(4)<<"*"<<setw(5)<<"*"<<endl;
  10.         cout<<"*"<<setw(9)<<"**"<<setw(6)<<"***"<<setw(6)<<"*"<<setw(4)<<"*"<<setw(10)<<"*****"<<endl;
  11.         return 0;
  12. }
复制代码


评分

参与人数 1鱼币 +20 收起 理由
康小泡 + 20 已评 20分

查看全部评分

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-1-29 22:46:41 | 显示全部楼层
刚刚恢复的特辣,其中用到想用这个功能:cout<<setfill(‘#’)<<123<<endl;
发现显示是: 参与_回复主题 - #鱼C五周年嘉年华#《C趣味》--第一发 - C_C  交流 - 鱼C论坛 - Power.png 有点诧异,有人可以解答吗?
顺便问问当用到在编程时经常会中英文切换,而有时用着中文来编写符号了,到运行时才发现错误,有人有什么技巧可以解决吗?总不能时不时盯着输入法吧。。。     这个问题如果不该在这个版块提问,烦请告之哪个版块?  谢谢^^
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-1-30 19:45:20 | 显示全部楼层

今天第一轮结束 每个星期回更新一次  最后要到2.23号才最终结束
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-1-30 19:48:29 | 显示全部楼层
知道了,谢谢啊!!!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-2-4 17:11:28 | 显示全部楼层
只能支持一下了。。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-2-4 17:54:33 | 显示全部楼层
特辣小菜#include <stdio.h>
#include<windows.h>

int main()
{   while(1){
    printf("*****          **              * * *         *                 *****\n");Sleep(200);
        printf("*                           *                *               *\n");Sleep(200);
        printf("*****          **           * *  *           ******         *\n");Sleep(200);
        printf("*              **                *           *    *          *\n");Sleep(200);
        printf("*              **           * * *            *    *            *****\n");Sleep(200);

         system("cls");Sleep(200);
}

           return 0;
}

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-2-4 18:45:21 | 显示全部楼层

回帖奖励 +5 鱼币

领鱼币
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-2-5 14:57:04 | 显示全部楼层

回帖奖励 +5 鱼币

对啊,看帖回帖,不知不觉就升级了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-2-6 15:49:01 | 显示全部楼层
#include <stdio.h>
#include<windows.h>

int main()
{   while(1){
    printf("*****          **              * * *         *                 *****\n");Sleep(200);
        printf("*                           *                *               *\n");Sleep(200);
        printf("*****          **           * *  *           ******         *\n");Sleep(200);
        printf("*              **                *           *    *          *\n");Sleep(200);
        printf("*              **           * * *            *    *            *****\n");Sleep(200);

         system("cls");Sleep(200);
}

           return 0;
}
特辣小菜。。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-2-7 14:42:35 | 显示全部楼层

回帖奖励 +5 鱼币

看看大神的代码,让新人学习一下
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-2-10 23:01:32 | 显示全部楼层
来晚了,直接上特辣吧,尽管还有很多可改进的地方

                               
登录/注册后可看大图
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-2-10 23:02:31 | 显示全部楼层
本帖最后由 _DEBUG 于 2015-2-10 23:06 编辑

  1. #include <Windows.h>
  2. #include <math.h>
  3. #include <time.h>

  4. #ifndef _countof
  5. #define _countof(a) (sizeof(a)/sizeof(a[0]))
  6. #endif

  7. HRESULT CALLBACK WindowProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);
  8. void DrawStar(HDC hdc,int cx,int cy);
  9. void DrawCharS(HDC hdc,int xLeft,int yTop,int xRight,int yBottom,int nThickness);
  10. void DrawCharHalfS(HDC hdc,int xLeft,int yTop,int xRight,int yBottom,int nThickness);
  11. void DrawStringFishc(HDC hdc,int xLeft,int yTop,int xRight,int yBottom,int nThickness);
  12. void DrawCharC(HDC hdc,int xLeft,int yTop,int xRight,int yBottom,int nThickness);
  13. void DrawFishc(HDC hdc);

  14. static int cxClient,cyClient;
  15. HRESULT CALLBACK WindowProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
  16. {
  17.         HDC hdc;
  18.         PAINTSTRUCT ps;
  19.         RECT rect;
  20.         switch(message)
  21.         {
  22.         case WM_PAINT:
  23.                 hdc = BeginPaint(hWnd,&ps);        
  24.                 DrawFishc(hdc);
  25.                 EndPaint(hWnd,&ps);
  26.                 break;
  27.         case WM_TIMER:
  28.                 GetClientRect(hWnd,&rect);
  29.                 InvalidateRect(hWnd,&rect,TRUE);
  30.                 break;
  31.         case WM_CREATE:
  32.                 SetTimer(hWnd,1,400,NULL);
  33.                 srand(time(NULL));
  34.                 break;
  35.         case WM_SIZE:
  36.                 cxClient = LOWORD(lParam);
  37.                 cyClient = HIWORD(lParam);
  38.                 break;
  39.         case WM_DESTROY:
  40.                 KillTimer(hWnd,1);
  41.                 PostQuitMessage(0);
  42.                 break;
  43.         default:
  44.                 return DefWindowProc(hWnd,message,wParam,lParam);
  45.         }
  46.         return 0;
  47. }

  48. void DrawStar( HDC hdc,int cx,int cy )
  49. {
  50.         XFORM xForm;
  51.         int i,savedState = SaveDC(hdc);
  52.         double theta = 0;
  53.         xForm.eDx  = 0.0;
  54.         xForm.eDy  = 0.0;
  55.         SetMapMode(hdc,MM_ISOTROPIC);
  56.         SetViewportOrgEx(hdc,cx/2,cy/2,NULL);
  57.         SetWindowExtEx(hdc,100,-100,NULL);
  58.         SetViewportExtEx(hdc,cx/2,cy/2,NULL);
  59.         SetGraphicsMode(hdc,GM_ADVANCED);
  60.         for(i=0;i<5;i++)
  61.         {
  62.                 xForm.eM11 = (FLOAT) cos(theta);
  63.                 xForm.eM12 = (FLOAT) sin(theta);
  64.                 xForm.eM21 = -xForm.eM12;
  65.                 xForm.eM22 =  xForm.eM11;
  66.                 SetWorldTransform(hdc, &xForm);               
  67.                 Rectangle(hdc,-10,90,10,0);
  68.                 theta += 72*3.1415926/180;
  69.         }
  70.         RestoreDC(hdc,savedState);
  71. }

  72. void DrawStringFishc( HDC hdc,int xLeft,int yTop,int xRight,int yBottom,int thick )
  73. {
  74.         XFORM xForm={0};
  75.         int savedState = SaveDC(hdc);
  76.         int w = (xRight-xLeft-2*thick)/7,h=yBottom-yTop-thick*2;
  77.         POINT ptF[]={0,0,w,0,w,thick,thick,thick,thick,h/2-thick/2,w,h/2-thick/2,w,h/2+thick/2,thick,h/2+thick/2,thick,h,0,h};        
  78.         POINT ptI[]={0,0,w,0,w,thick,(w-thick)/2+thick,thick,(w-thick)/2+thick,thick+(h-2*thick),w,thick+(h-2*thick),w,h,
  79.         0,h,0,h-thick,(w-thick)/2,h-thick,(w-thick)/2,thick,0,thick};
  80.         POINT ptH[]={0,0,thick,0,thick,(h-thick)/2,w-thick,(h-thick)/2,w-thick,0,w,0,w,h,
  81.         w-thick,h,w-thick,(h+thick)/2,thick,(h+thick)/2,thick,h,0,h};
  82.         
  83.         OffsetViewportOrgEx(hdc,xLeft,yTop,NULL);

  84.         OffsetViewportOrgEx(hdc,thick,thick,NULL);
  85.         //&Oacute;&Atilde;&para;à±&szlig;&ETH;&Icirc;&raquo;&aelig;&Ouml;&AElig;×&Ouml;&Auml;&cedil;F&iexcl;&pound;
  86.         Polygon(hdc,ptF,_countof(ptF));
  87.         OffsetViewportOrgEx(hdc,w*3/2,0,NULL);
  88.         //&Oacute;&Atilde;&para;à±&szlig;&ETH;&Icirc;&raquo;&aelig;&Ouml;&AElig;×&Ouml;&Auml;&cedil;I&iexcl;&pound;
  89.         Polygon(hdc,ptI,_countof(ptI));
  90.         //&raquo;&aelig;&Ouml;&AElig;×&Ouml;&Auml;&cedil;S&iexcl;&pound;
  91.         OffsetViewportOrgEx(hdc,w*3/2,-thick/2,NULL);
  92.         DrawCharS(hdc,0,0,w,h+thick,thick);
  93.         OffsetViewportOrgEx(hdc,w*3/2,thick/2,NULL);
  94.         //&Oacute;&Atilde;&para;à±&szlig;&ETH;&Icirc;&raquo;&aelig;&Ouml;&AElig;×&Ouml;&Auml;&cedil;H&iexcl;&pound;
  95.         Polygon(hdc,ptH,_countof(ptH));
  96.         OffsetViewportOrgEx(hdc,w*3/2,0,NULL);
  97.         //&raquo;&aelig;&Ouml;&AElig;×&Ouml;&Auml;&cedil;C&iexcl;&pound;
  98.         DrawCharC(hdc,0,0,w,h,thick);

  99.         RestoreDC(hdc,savedState);
  100. }
  101. void DrawCharS( HDC hdc,int xLeft,int yTop,int xRight,int yBottom,int nThickness )
  102. {
  103.         int nSavedDC;
  104.         XFORM xForm={0};
  105.         nSavedDC = SaveDC(hdc);
  106.         xForm.eM11 = xForm.eM22 = -1;//cos(&brvbar;&ETH;)

  107.         OffsetViewportOrgEx(hdc,0,nThickness/2,NULL);
  108.         DrawCharHalfS(hdc,xLeft,yTop,xRight,(yTop+yBottom)/2,nThickness);
  109.         OffsetViewportOrgEx(hdc,0,(yBottom-yTop)/2-nThickness,NULL);

  110.         SetGraphicsMode(hdc,GM_ADVANCED);
  111.         SetWorldTransform(hdc,&xForm);
  112.         DrawCharHalfS(hdc,xLeft,yTop,xRight,(yTop+yBottom)/2,nThickness);
  113.         
  114.         RestoreDC(hdc,nSavedDC);
  115. }

  116. void DrawCharHalfS( HDC hdc,int xLeft,int yTop,int xRight,int yBottom,int nThickness )
  117. {
  118.         HBRUSH hBrush;
  119.         LOGPEN pen;
  120.         HRGN hRgnLargeEllipse,hRgnSmallEllipse,hRgnRect,hRgn,hRgnTemp;
  121.         int rx,ry,nSavedDC = SaveDC(hdc);
  122.         
  123.         rx = (xRight-xLeft)/2;
  124.         ry = (yBottom-yTop)/2;
  125.         OffsetViewportOrgEx(hdc,rx,ry,NULL);
  126.         
  127.         hRgnLargeEllipse = CreateEllipticRgn(-rx,-ry,rx,ry);
  128.         hRgnSmallEllipse = CreateEllipticRgn(-(rx-nThickness),-(ry-nThickness),rx-nThickness,ry-nThickness);
  129.         hRgnRect = CreateRectRgn(0,-ry/4,rx,ry);
  130.         hRgn = CreateRectRgn(0,0,1,1);
  131.         hRgnTemp = CreateRectRgn(0,0,1,1);
  132.         CombineRgn(hRgnTemp,hRgnLargeEllipse,hRgnRect,RGN_DIFF);
  133.         CombineRgn(hRgn,hRgnTemp,hRgnSmallEllipse,RGN_DIFF);
  134.         
  135.         PaintRgn(hdc,hRgn);        
  136.         GetObject(GetCurrentObject(hdc,OBJ_PEN),sizeof(pen),&pen);
  137.         if(pen.lopnStyle != PS_NULL)
  138.         {
  139.                 hBrush = CreateSolidBrush(pen.lopnColor);
  140.                 FrameRgn(hdc,hRgn,hBrush,1,1);
  141.                 DeleteObject(hBrush);
  142.         }
  143.         
  144.         DeleteObject(hRgnLargeEllipse);
  145.         DeleteObject(hRgnSmallEllipse);
  146.         DeleteObject(hRgnRect);
  147.         DeleteObject(hRgn);
  148.         DeleteObject(hRgnTemp);
  149.         
  150.         RestoreDC(hdc,nSavedDC);
  151. }
  152. void DrawCharC( HDC hdc,int xLeft,int yTop,int xRight,int yBottom,int nThickness )
  153. {
  154.         HBRUSH hBrush;
  155.         LOGPEN pen;
  156.         HRGN hRgnLargeEllipse,hRgnSmallEllipse,hRgnRect,hRgn,hRgnTemp;
  157.         int rx,ry,nSavedDC = SaveDC(hdc);
  158.         
  159.         rx = (xRight-xLeft)/2;
  160.         ry = (yBottom-yTop)/2;
  161.         OffsetViewportOrgEx(hdc,rx,ry,NULL);
  162.         
  163.         hRgnLargeEllipse = CreateEllipticRgn(-rx,-ry,rx,ry);
  164.         hRgnSmallEllipse = CreateEllipticRgn(-(rx-nThickness),-(ry-nThickness),rx-nThickness,ry-nThickness);
  165.         hRgnRect = CreateRectRgn(0,-ry/2,rx,ry/2);
  166.         hRgn = CreateRectRgn(0,0,1,1);
  167.         hRgnTemp = CreateRectRgn(0,0,1,1);
  168.         CombineRgn(hRgnTemp,hRgnLargeEllipse,hRgnRect,RGN_DIFF);
  169.         CombineRgn(hRgn,hRgnTemp,hRgnSmallEllipse,RGN_DIFF);        
  170.         
  171.         PaintRgn(hdc,hRgn);
  172.         GetObject(GetCurrentObject(hdc,OBJ_PEN),sizeof(pen),&pen);
  173.         if(pen.lopnStyle != PS_NULL)
  174.         {
  175.                 hBrush = CreateSolidBrush(pen.lopnColor);
  176.                 FrameRgn(hdc,hRgn,hBrush,1,1);
  177.                 DeleteObject(hBrush);
  178.         }
  179.         
  180.         DeleteObject(hRgnLargeEllipse);
  181.         DeleteObject(hRgnSmallEllipse);
  182.         DeleteObject(hRgnRect);
  183.         DeleteObject(hRgn);
  184.         DeleteObject(hRgnTemp);
  185.         
  186.         RestoreDC(hdc,nSavedDC);
  187. }
  188. void DrawFishc(HDC hdc)
  189. {
  190.         HDC hdcMem;
  191.         HBRUSH hBrush;
  192.         HBITMAP hBitmap;
  193.         int a;
  194.         RECT rect,rcClient={0,0,cxClient,cyClient};
  195.         int nMinW=cxClient/3,nMinH=cyClient/3;
  196.         
  197.         FillRect(hdc,&rcClient,GetStockObject(WHITE_BRUSH));

  198.         rect.left = rand()%(cxClient-nMinW);
  199.         rect.top  = rand()%(cyClient-nMinH);
  200.         rect.right = nMinW+rand()%(cxClient-nMinW-rect.left+1);//&iquest;í&para;&Egrave;&iexcl;&pound;
  201.         a = (2+rand()%3);//2-4
  202.         rect.bottom = rect.right/a;//&cedil;&szlig;&para;&Egrave;&iexcl;&pound;
  203.         if(rect.bottom>cyClient-rect.top)
  204.         {
  205.                 rect.bottom = nMinH+rand()%(cyClient-nMinH-rect.top+1);//&cedil;&szlig;&para;&Egrave;&iexcl;&pound;
  206.                 rect.right = rect.bottom*a;
  207.         }
  208.         else if(rect.bottom<nMinH)
  209.         {
  210.                 rect.bottom = nMinH;
  211.                 rect.right = nMinW;
  212.         }
  213.         rect.right += rect.left;
  214.         rect.bottom += rect.top;
  215.         a = (int)hypot(rect.right-rect.left,rect.bottom-rect.top)/30;


  216.         hdcMem = CreateCompatibleDC(hdc);
  217.         hBitmap = CreateCompatibleBitmap(hdc,a,a);
  218.         SelectObject(hdcMem,hBitmap);
  219.         SetRect(&rcClient,0,0,a,a);
  220.         InvertRect(hdcMem,&rcClient);

  221.         hBrush = CreateSolidBrush(RGB(rand()%256,rand()%256,rand()%256));
  222.         SelectObject(hdcMem,hBrush);
  223.         DrawStar(hdcMem,a,a);
  224.         SelectObject(hdc,CreatePatternBrush(hBitmap));

  225.         DrawStringFishc(hdc,rect.left,rect.top,rect.right,rect.bottom,a);
  226.         
  227.         DeleteDC(hdcMem);
  228.         DeleteObject(hBrush);
  229.         DeleteObject(hBitmap);
  230.         DeleteObject(SelectObject(hdc,GetStockObject(WHITE_BRUSH)));
  231. }
  232. int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd )
  233. {
  234.         WNDCLASS wndcls;
  235.         HWND hWnd;
  236.         TCHAR *szClassName = TEXT("MyWin32App");
  237.         MSG msg;
  238.         
  239.         wndcls.cbClsExtra  = 0;
  240.         wndcls.cbWndExtra = 0;
  241.         wndcls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  242.         wndcls.hCursor = LoadCursor(NULL,IDC_ARROW);
  243.         wndcls.hIcon = LoadIcon(NULL,IDI_APPLICATION);
  244.         wndcls.hInstance = hInstance;
  245.         wndcls.lpfnWndProc = WindowProc;
  246.         wndcls.lpszClassName = szClassName;
  247.         wndcls.lpszMenuName = NULL;
  248.         wndcls.style = CS_HREDRAW | CS_VREDRAW;     
  249.       
  250.         
  251.         if(!RegisterClass(&wndcls))
  252.         {
  253.                 MessageBox(NULL,TEXT("×&cent;&sup2;á&acute;°&iquest;&Uacute;&Agrave;à&Ecirc;§°&Uuml;&pound;&iexcl;"),NULL,MB_ICONERROR);
  254.                 return -1;
  255.         }
  256.         hWnd = CreateWindow(szClassName,TEXT("C&Oacute;&iuml;&Ntilde;&Ocirc; Win32 &sup3;&Igrave;&ETH;ò"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,0);        
  257.         ShowWindow(hWnd,nShowCmd);
  258.         UpdateWindow(hWnd);
  259.         
  260.         while(GetMessage(&msg,NULL,0,0))
  261.         {
  262.                 TranslateMessage(&msg);
  263.                 DispatchMessage(&msg);
  264.         }        
  265.         return msg.wParam;
  266. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-3-9 17:35:09 | 显示全部楼层
include <stdio.h>
#include <windows.h>
void main()
{
    int  i , j;
    for (i=0;i < 65;i++)
    {
            for (j=0 ;j < i ;j++)
            {
                printf(" ");
            }

           printf("Welcome to Fishc");

           system("cls");
    }
   
   
}
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-3-9 17:35:48 | 显示全部楼层
学习 了,有意思的活动
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-23 23:44

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表