小考一討論區

tatar 發表在 痞客邦 留言(1) 人氣()

  • Mar 26 Mon 2018 09:35
  • Array

#include <stdio.h>
#include <stdlib.h>
#define size 20
int GiveValue(int A[], int n){
   for(int a=0;a<n;a++) A[a]=a;
   
   return 1;

tatar 發表在 痞客邦 留言(0) 人氣()

[1] 完成 Input n; Output : 1 + 2 + ... + n 
#include <stdio.h>
#include <stdlib.h>
int main(){
    int n,r;
    scanf("%d",&n);
    
    r=0;
    for(int i=1;i<=n;i++){
       r = r + i;      
    }
    
    printf("%d\n",r);
    system("pause");
    return 1;
}
 

tatar 發表在 痞客邦 留言(1) 人氣()

int main(int argc, char *argv[]) {
    int a,b;
    char c;
    printf("請輸入一個時間:");
    scanf("%d%c%d",&a,&c,&b);
    
    if((a >= 5) && (a <= 17)){
        printf("白天");
    }
    else if((a == 18) && (b == 0)){
        printf("白天");
    }
    else if((a >= 18) || (a <= 4)){
        printf("晚上");
    }
    return 0;
}

tatar 發表在 痞客邦 留言(0) 人氣()

題目:
輸入一數值 剪刀為0 石頭1 布為2,與電腦進行猜拳並判定勝負

tatar 發表在 痞客邦 留言(1) 人氣()


題目:
程式碼:

tatar 發表在 痞客邦 留言(1) 人氣()


題目:
程式碼:

tatar 發表在 痞客邦 留言(0) 人氣()

以下100題請在留言區 寫下你的程式
1. 將一連串數字(每個數字為0~9)輸入, 計算其和. Ex: 輸入 12345, 輸出為 15 (1+2+3+4+5=15)

tatar 發表在 痞客邦 留言(1) 人氣()

1. 將一連串數字(每個數字為0~9)輸入, 計算其和. Ex: 輸入 12345, 輸出為 15 (1+2+3+4+5=15)
2. 輸入一個字串, 並把它反向輸出

tatar 發表在 痞客邦 留言(4) 人氣()

/*
輸入一 1000以內的整數,判斷此整數是否為回文; 123反過來321不是回文; 121反過來121 是回文; 
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int a,b,c,d,e;  // a:輸入的整數  b:a的百位數, c:a的十位數 d:a的個位數  e:a的反轉 (=100*d+10*c+b;)
   int t;
   scanf("%d",&a); // 設 a=121 (or 123)
   t=a;
   b=(int)t/100;   // b=(int)121/100=1 or (int)123/100=1
   t=t-100*b;      // t=121-100*1=21   or t=123-100*1=23 
   c=(int)t/10;    // c=(int)21/10=2;  or c=(int)23/10=3; 
   t=t-10*c;       // t=21-10*2=1;  or t=23-10*2=3;
   d=t;            //d=1  or d=3;
   
   //printf("test %d %d %d %d %d",a,b,c,d,e);
   e=100*d+10*c+b;    //e=100*1+10*2+1=121   or e=100*3+10*2+1=321
   
   if(a==e) printf("%d 是回文",a);  // 121 是回文  123 不是回文
   else printf("%d!=%d 不是回文",a,e); 
   
   printf("\n\n"); system("pause");

tatar 發表在 痞客邦 留言(0) 人氣()

C#C++#程式設計觀念複習:宣告變數 指定數值 運算 印結果 
 基本I/O : 變數,printf 和scanf 就可完成的題目
這單元的題目是,只需要4個步驟就可完成 
1. 宣告變數
2. 變數給值
3. 運算
4. 印結果 

tatar 發表在 痞客邦 留言(0) 人氣()

/* 資料結構#鏈結串列#串列合併 
串列的合併 
(1) 用GenList 產生 l1和 l2
(2) 將 l1和 l2合併 
*/
#include <stdio.h>
#include <stdlib.h>

tatar 發表在 痞客邦 留言(0) 人氣()

1 2
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。