20160125.CPP詳細体系(0004日)

19380 ワード

プログラムセグメント(01):ワイド文字.c内容概要:ワイド文字
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>

//01.         :
// 1.           :
// (1).              ,    ,    
// (2).         ,         ,           
//                       ,      ,    
// 2.                 :
//    :
//           ,          
//    :
//     (           )        
// 3.             :
// MessageBox();
// (1).       
// (2).       :
//   ,  Unicode   ,             
//   ,        ,            ,      
// MessageBox();+TEXT():   
// (1).            
// (2).       ,      TEXT();    
//   TEXT():              
//           (        )
//           ,          (    )
// MessageBoxA();
// (1).          
// (2).            
// MessageBoxW();
// (1).    Unicode   
// (2).            


int main01(void)
{
    char ch = 'A';//     ,    
    wchar_t ch1 = L'0';//         ,     ,    
    printf("%d, %d 
"
, sizeof(char), sizeof(wchar_t)); printf("%d, %d
"
, sizeof(ch), sizeof(ch1)); printf("%d
"
,sizeof("1 "));//4byte printf("%d
"
,sizeof(L"1 "));//6byte "1" ," " ,"\0" -->3 //MessageBox(0, L" !", L" !", 0); // Unicode, MessageBox(0, L" !", L" !", 0); // , MessageBox(0, " !", " !", 0); // : // Unicode, // , //A , MessageBoxA(0, " !", " !", 0); //W Unicode, MessageBoxW(0, L" !", L" !", 0); //TEXT , , MessageBox(0, TEXT(" !"), TEXT(" !"), 0); system("pause"); return 1; }

プログラムセグメント(02):ワイド文字処理.c内容概要:ワイド文字処理
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>//             

//01.      :
// 1.           ,       ,          ,         
// 2.        ,                 
// %s:              ,           
// %c%c:                   ,         
int main01(void)
{
    char str[10] = " ";//                  
    printf("%s 
"
, str);// printf("%c%c
"
, str[0], str[1]);// ( ) system("pause"); return 1; } //02. : // 1. : // :#include <locale.h> // :setlocale(LC_ALL, "zh-CN"); // 2. , // L // 3. : // L"%ls" int main02(void) { setlocale(LC_ALL, "zh-CN");// ( ) //wchar_t wstr[10] = L"1234"; wchar_t wstr[10] = L"1234 !";// wprintf, wprintf(L"%ls
"
, wstr);//L,l system("pause"); return 1; } //03. ('') int main(void) { setlocale(LC_ALL, "zh-CN"); wchar_t ch = L' '; putwchar(ch); system("pause"); return 1; } int main04(void) { char ch = 'A'; wchar_t wch = L'A'; printf("%d
"
, wch); system("pause"); return 1; } int main05(void) { setlocale(LC_ALL, "zh-CN"); //printf("%s", L" ");// wprintf(L"%ls", L" "); system("pause"); return 1; }

プログラムクリップ(03):auto.c内容概要:autoキーワード
#include <stdio.h>

//01.auto       :
// 1.           
// 2.          :
//   auto                    

void go(void)
{
    int num = 10;
    printf("%p 
"
, &num); } int main01(void) { auto int num = 10;// go(); printf("AAAAAAAAAAAAAAAA
"
); go(); printf("AAAAAAAAAAAAAAAA
"
); system("pause"); return 1; }

プログラムセグメント(04):main.cpp内容概要:autoキーワードQtテスト
#include "mainwindow.h"
#include <QApplication>

void go()
{
  MainWindow w;//  
  w.show();
}

int main(int argc, char *argv[])
{
   QApplication a(argc, argv);

   go();

   return a.exec();
}

プログラムフラグメント(05):bool.c内容概要:C 99構文補完_Bool
#include <stdio.h>
#include <stdlib.h>

//01. C99         C       :
// 1._Bool  
// 2.      
// 3.true( 0)|false(0)-->      
int main01(void)
{
    _Bool bl = 10;//true|false  0|0

    printf("%d 
"
, bl); printf("%d
"
, sizeof(bl));// bl ? printf(" !
"
) : printf(" !
"
); system("pause"); return 1; }

プログラムフラグメント(06):int.c内容概要:整数の操作意義
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

//01.      :
// for /l %i in (1,1,5) do
int main01(void)
{
    char cmd[100];
    int N;
    scanf("%[^
]"
, cmd);// scanf("%d", &N); char strcmd[200] = { 0 }; sprintf(strcmd, "for /l %%i in (1,1,%d) do %s", N, cmd);// //printf("%s", strcmd); system(strcmd); system("pause"); return 1; }

プログラムセグメント(07):Test.c内容概要:かじり演算法則解析
#include <stdio.h>
#include <stdlib.h>

//01.  :
// 1.           ,         
//        ++db      db++  
//                
// 2.          ?
//                     
//                    
//           
int main01(void)
{
    printf("Hello World!!! 
"
); double db = 1; //double y = ++db*++db;//9 //double y = db++*db++;//1 double y = db++ + db++ + db++;//3 //printf("%p
", &db);
printf("%f
"
, y); system("pause"); return 1; }

プログラムセグメント(08):乱数.c内容概要:賭博機実現
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

//01.      :
// 1.    0~100     
// 2.      >=80     
//    20%
//02.       :
// 1.     
// 2.     
// 3.     
// 4.     
int main01(void)
{
    time_t ts;
    unsigned int num = time(&ts);//           
    srand(num);

    int data = rand() % 100;//              
    printf("%d 
"
, data); system("pause"); return 1; } int main02(void) { time_t ts; unsigned int num = (unsigned int)time(&ts); srand(num); int data = rand() % 100; printf("%d
"
, data); data >= 90 ? printf("
"
) : printf("
"
); system("pause"); return 1; }

プログラムセグメント(09):可視文字を印刷する.c内容概要:可視文字の印刷
#include <stdio.h>
#include <stdlib.h>

//01.      :
// 1.    :
// ASCII   32~126           
// 2.     :
// ASCII   32~126            
int main01(void)
{
    for (int i = 32; i < 127; i++)
    {
        putchar(i);
    }

    system("pause");
    return 1;
}

プログラムセグメント(10):main.c内容概要:簡易ソート
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  // a,b,c                 
  (a > b) ? (a=a^b,b=a^b,a=a^b) : 0;
  (a > c) ? (a=a^c,c=a^c,a=a^c) : 0;
  (b > c) ? (b=b^c,c=b^c,b=b^c) : 0;
  //a=a^b,b=a^b,a=a^b;               
  printf("%d, %d, %d 
"
, a, b, c);// system("pause"); return 1; }