首页    新闻    小组    威客    人才    下载    博客    代码贴    在线编程    论坛
代码贴随便看看C语言
while((*gets(buffer) !='\n') && (i<8))
{
pS[i]=(char *)malloc(strlen(buffer)+1);

if(pS[i]==NULL)                            /* Check for no memory allocated */
{
      printf("Memory allocation failed.Program terminated.\n");
      return;
}
strcpy(pS[i++],buffer);


......................
阅读全部 | Bingo_yue 贴于 2016年1月11日 14:17     hide bbsi
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
#define Z 5
#define R 4                   /*定义宏常量便于程序的一般化*/ /*R表示销售员个数*/
typedef struct                 /*缩短结构体变量名*/
{  int shangpin[Z];          /*定义结构体便于信息的存储和读写,辨别*/
}data; /*R是表示商品的种类,最后一个为该销售员商品总和*/


......................
阅读全部 | xu847628954 贴于 2016年1月10日 15:17     hide bbsi
我想在这一个学生管理程序中加个登录界面,但是加不来。可不可以教一下我哦!
【#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define SIZE 3 /*定义常量SIZE便于以后的修改*/

struct student /*定义一个结构体数组存放学生的信息*/

{
......................
阅读全部 | 罗琪琪 贴于 2016年1月1日 16:41     hide bbsi
#include <stdio.h>
void swap(int *p1,int *p2) //聲明函數
void main()
{
int a1,a2;
int *ptr1,*ptr2; //定義指向整型變量的指針
printf("請輸入兩個整數:\n");
scanf("%d,%d",&a1,&a2);
ptr1=&a1; //ptr1指向a1
ptr2=&a2; //ptr2指向a2
printf("&a1=%p,&a2=%p\n",&a1,&a2); //輸出a1和a2的地址
printf("ptr1=%p,ptr2=%p\n",ptr1,ptr2); //輸出ptr1和ptr2的值(即指向變量的地址)
......................
阅读全部 | guangyuanhh 贴于 2015年12月29日 02:59     hide bbsi
#include <stdio.h>

#define N 999

int a[N],b[N];

int main(void)
{
int i,j;
a[0]=a[1]=1;
for(i=2; i<N; i++)
{
......................
阅读全部 | wp231957 贴于 2015年12月28日 14:08     hide bbsi
#include <stdio.h> 
#include <windows.h>
#include <string.h>

#import "c:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")   //引入ADO库

int main(void)
{
    _ConnectionPtr m_pConnection=NULL;
    CoInitialize(NULL);  //初始化com库
    HRESULT hr = m_pConnection.CreateInstance("ADODB.Connection");    //创建Connection对象
    if(SUCCEEDED(hr))  //创建数据库connection对象成功
......................
阅读全部 | wp231957 贴于 2015年12月22日 14:29     hide bbsi
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 215
typedef struct stankl{
  char* top;
  char* base;
int stacksize;
} stackl,*linkstack;
linkstack Initstack(){
    stackl *l=NULL;
  l->base=(char*)malloc(100* sizeof(char));
  if(!l->base) exit(-1);
......................
阅读全部 | absly 贴于 2015年12月21日 23:04     hide bbsi
#include <stdio.h>

//利用泰勒公式计算星期几
//w=y+[y/4]+[c/4]-2c+[26(m+1)/10]+d-1 
int getweek(int year,int month,int day)
{
int w;    //星期
int c;    //世纪-1 YYYY的头两位
int y;    //年份   YYYY的后两位
int m;    //月份 >=3 1月 2月看成上年的13月 14月
int d=day;    //日
if(month>=3) 
......................
阅读全部 | wp231957 贴于 2015年12月18日 15:20     hide bbsi
//1. (**)随机产生20个[10 , 100]的正整数,输出这些数以及他们中的最大数
    {
        int max = 10, num;
        printf("随机产生20个[10 , 100]的正整数:");
        for (int i = 1; i <= 20; i++) {
            num = arc4random() % (1000 - 10 + 1) + 10;
            printf("%d ", num);
            max = num > max ? num : max;
        }
        printf("\n最大数为:%d\n", max);
    }
//2. (**)编程将所有“水仙花数”打印出来,并打印其总个数。 “水仙花数”是一个 各个位立方之和等于该整数的三位数。
......................
阅读全部 | Raised丶Jay 贴于 2015年11月30日 13:50     hide bbsi
#include <stdio.h>
#define N 9
void init(char a[N][N]){
int i, j;
char temp;
FILE *fp = fopen("data.txt", "r");
for(i = 0; i < N; i++)
for(j = 0; j < N; j++)
{
fscanf(fp, "%c", &temp); //读书文件中的初始数据,符号 .  代表空格子
if(((temp > 48) && (temp < 58))|| (temp == '.'))
a[i][j] = temp;
......................
阅读全部 | dantongxo 贴于 2015年11月25日 17:46     hide bbsi
上一页 97 98 99 100 101 102 103 104 105 106 下一页