第一次写博客

 好久以前就有人建议我写博客,而且我也想写写博客,可是因为各种忙,各种活动,所以一直都没有落实。到了今天我觉得不能再托下去了所以决定写写博客,顺便记录一下我的成长历程。

  老规矩还是以一个Hello World 为开始吧!

#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    cout<<"Hello World!!"<<endl;
    return 0;
}


经典的例子,膜拜一下!!!

恩恩,接下来些写个冒泡排序吧

#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    void arry_up(int *num,const int BOUNDS);
    int num[10];
    const int BOUNDS = 10;
    cout<<"Please enter ten numbers!:"<<endl;
    for(int i = 0;i < BOUNDS;i++)
        cin>>num[i];
    arry_up(num,BOUNDS);
    for(int i = 0;i < BOUNDS;i++)
        cout<<num[i]<<"  ";
    cout<<endl;
    return 0;
}

void arry_up(int *num,const int BOUNDS)
{
    for(int i = 0;i < BOUNDS-1;i++)
        for(int j = 0;j < BOUNDS-1-i;j++)
            if(num[j]>num[j+1])
            {
                int temp = num[j+1];
                num[j+1] = num[j];
                num[j] = temp;
            }
}



这都是些简单的例子就偷偷懒不加注释了吐舌头

  再来个蛇形矩阵

#include "stdafx.h"
#include<iostream>
#include<iomanip>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    int n1,n2,j,k,i;
    int a[10][10];
    for(n1=0;n1<10;n1++)
    {
        j=1;k=2+n1;
        a[n1][0]=(((n1+1)*(n1+1)-(n1+1))/2)+1;
        for(n2=0;n2<9-n1;n2++,j++)
        {    
            a[n1][j]=a[n1][j-1]+k;
            k=k+1;
        }
    }
    for(i=0;i<10;i++)
    {
        for(j=0;j<10-i;j++)
            cout<<setw(3)<<a[i][j]<<" ";
        cout<<endl;
    }
    cout<<endl;
    return 0;
}


写个闰年判断程序纪念纪念

#include "stdafx.h"
#include<stdio.h>
int main()
{
    int year;
    scanf("%d",&year);
    (year%4==0&&year%100!=0)||year%400==0?printf("闰年"):printf("非闰年");

    return 0;
}


这些程序代码都是我在刚入学时敲得(当然我不可能就敲这么点,只是觉得比较经典就发上来了大家别喷……哈哈),当时敲得代码能成功运行别提有多激动了可怜




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值