廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 3538 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
dnnn 手機 會員卡
數位造型
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x4 鮮花 x33
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[C/C++][求助] dev c++ 請幫忙解!!謝謝
因為弟弟要交期未報告,沒有交死當,而我又無能為力,所以想請各位知識者幫忙。



請設計一個統記班長選舉後選人的票數之程式 假定後選人共有6名
其編 ..

訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容



[ 此文章被dnnn在2007-06-27 01:27重新編輯 ]


獻花 x0 回到頂端 [樓 主] From:臺灣東森寬頻 | Posted:2007-06-26 23:20 |
ducktw
個人文章 個人相簿 個人日記 個人地圖
路人甲
級別: 路人甲 該用戶目前不上站
推文 x0 鮮花 x14
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

1.#include <stdio.h>     /* 氣泡排序法 Bubble Sort */

void main(void) {
  int data[50];
  int i,j,n,temp;

  printf("輸入數值的個數: ");   /*輸入n */
  scanf("%d" ,&n);
  printf("\n");
  if (n > 49) {
    printf("請輸入小於49的數字\n");
    return;
  }
  for (i = 1;i <= n;i++) {     /*輸入 n 個數值 */
    printf("請輸入數值:");
    printf("data[%d]=", i);
    scanf("%d", &data);
  }
  for (i=1; i <= n; i++) {
    for (j = n; j > i; j--) {
        if (data[j-1] > data[j]) { /*若 data[j-1] > data[j],則兩個值交換 */
          temp = data[j-1];
          data[j-1] = data[j];
          data[j] = temp;
        }
    }
  }
  printf("\n資料排序後為\n");
  for (i = 1; i <= n; i++) {
    printf("%d ", data);
  }
}

2.#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
  int qty = 0;
  int qtycnt = 1; //計算人數迴圈用(兼最後顯示迴圈用)
  int i = 0;
  int studren[50]={0};
  char tot[][57]={" 100 :","90-99 :","80-89 :","70-79 :","60-69 :","50-59 :",
          "40-49 :","30-39 :","20-29 :","10-19 :"," 0- 9 :"};
  char tmt[][57]={" 100 :","90-99 :","80-89 :","70-79 :","60-69 :","50-59 :",
          "40-49 :","30-39 :","20-29 :","10-19 :"," 0- 9 :"};
  while(1)
  {
    printf("\n請輸入學生人數(最多 50 人,輸入 0 結束):");
    scanf("%d",&qty);
    if(qty==0)
      break;

    if(qty > 0 && qty <= 50)
    {
      printf("請輸入學生分數\n");
      for( qtycnt=1 ; qtycnt<=qty ; qtycnt++ )
      {
        while(1)
        {
          printf("第 %d 位 : ",qtycnt);
          scanf("%d",&studren[qtycnt]);
          if(studren[qtycnt] >= 0 && studren[qtycnt] <= 100)
          {
            if(studren[qtycnt]==0)
            {
              strcat(tot[10],"=");
              break;
            }
            else
            {
              switch(studren[qtycnt]/10)
              {
                case 10:
                  strcat(tot[0],"=");
                  break;
                case 9:
                  strcat(tot[1],"=");
                  break;
                case 8:
                  strcat(tot[2],"=");
                  break;
                case 7:
                  strcat(tot[3],"=");
                  break;
                case 6:
                  strcat(tot[4],"=");
                  break;
                case 5:
                  strcat(tot[5],"=");
                  break;
                case 4:
                  strcat(tot[6],"=");
                  break;
                case 3:
                  strcat(tot[7],"=");
                  break;
                case 2:
                  strcat(tot[8],"=");
                  break;
                case 1:
                  strcat(tot[9],"=");
                  break;
                case 0:
                  strcat(tot[10],"=");
                  break;
                default:
                  break;
              }
            }
            break;
          }
          else
          {
            printf("您的手大概抽筋,分數只能從 0~100\n");
          }
        }
      }
      printf("\n=== 成績分布橫條圖 ===\n");
      for(qtycnt=0;qtycnt<=10;qtycnt++)
      {
        printf("%s\n",tot[qtycnt]);
        strcpy(tot[qtycnt],tmt[qtycnt]);
      }
    }
    else
    {
      printf("輸入錯誤,請重新輸入!\n");
      system("PAUSE");
    }
  }
  return 0;
}

以上"幾乎"是您要的解答,自己再修改一下吧,最好別用死當爭取同情,真的不會被當並不冤枉

不然拿到的文憑也是屬於別人的,相信沒人希望身體不適時看的醫生是靠別人畢業的,或是搭船

搭飛機搭高鐵時,設計或建造這些設備的工程師是靠別人畢業的,您說對吧


不妄君臨天下,但求傲骨清風
獻花 x0 回到頂端 [1 樓] From:上海 | Posted:2007-06-27 07:16 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.020457 second(s),query:16 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言