原创 求一個整數中二進制中1的個數

 第一種方法#include<stdio.h>int b(int unsigned a){ int count = 0; while (a) {    if (a % 2 == 1)  {   count++;  }  a = a / 2;

原创 宏和函數的區別

先說宏和函數的區別:1. 宏做的是簡單的字符串替換(注意是字符串的替換,不是其他類型參數的替換),而函數的參數的傳遞,參數是有數據類型的,可以是各種各樣的類型.2. 宏的參數替換是不經計算而直接處理的,而函數調用是將實參的值傳遞給形參,既然

原创 鏈表的操作

#include "stdafx.h" #include "stdio.h" #include <stdlib.h> #include "string.h"   typedef int elemType ;   /*************

原创 求Sn=a+aa+aaa+aaaa+aaaaa的前5項之和,其中a是一個數字,例如:2+22+222+2222+22222

#include<stdio.h>int main(){ int a = 0; int n = 0; int sum = 0; int tmp = 0; int i = 0; scanf("%d%d", &a, &n); for (i =

原创 對於strrstr函數的實現

#include<stdio.h>char const  *my_strrstr(char const *str, char const *dst){ char const *ret = NULL; char const *cur = my

原创 1到1000的水仙花數

#include <stdio.h>int main(){ int i, a, b, c; for (i = 100; i <= 999; i++){  a = i / 100;    b = (i % 100) / 10;    c =

原创 結構體的定義及使用

結構體的定義定義一個結構的一般形式爲:struct 結構名{成員表列}成員表由若干個成員組成,每個成員都是該結構的一個組成部分。對每個成員也必須作類型說明。例如:struct stu{int num;char name[20];int ag

原创 c語言實現ATM機

#include<stdio.h>#include<stdlib.h>void chaxun(a3){ int b; b = a3; printf("您的餘額:%d\n", b);}int qukuan(int a3){ int a=0,

原创 宏和函數的區別

先說宏和函數的區別:1. 宏做的是簡單的字符串替換(注意是字符串的替換,不是其他類型參數的替換),而函數的參數的傳遞,參數是有數據類型的,可以是各種各樣的類型.2. 宏的參數替換是不經計算而直接處理的,而函數調用是將實參的值傳遞給形參,既然

原创 利用指針變量 調用函數實現3個數的排序

#include<stdio.h>void exchange(int *q1, int *q2, int *q3){ void swap(int *w1, int *w2); if (*q1 < *q2)swap(q1, q2);//這裏的

原创 c語言實現猜數字小遊戲

#include<stdio.h>#include<stdlib.h>#include<time.h>  void fun(int c ){ srand((unsigned)time(NULL)); int ret = rand() % 1

原创 輸入1234求最多可以組成不重複的多少個3位數

#include<stdio.h>int main(){ int a = 0, b = 0, c = 0, count=0; for (a = 1; a < 5; a++) for (b = 1; b < 5; b++) for (c =

原创 函數堆棧調用過程

從內存的角度詳細的分析C語言中的函數調用過程:首先寫一個測試用的代碼:#include <stdio.h> int add(int x, int y) { int z = 0; z = x + y; return z; } int

原创 鏈表的操作

#include "stdafx.h" #include "stdio.h" #include <stdlib.h> #include "string.h"   typedef int elemType ;   /*************

原创 實現一個strcpy函數

#include<stdio.h>#include<assert.h>char   my__strcpy(char*dest, const char *src){assert(dest != NULL);assert(src);while