亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

c語言,把代碼結果輸出到E盤上一個叫1.txt的文本文檔上

c語言,把代碼結果輸出到E盤上一個叫1.txt的文本文檔上

C++
慕斯709654 2018-07-23 11:22:13
#include "stdafx.h"#includeint main(){int a, b, c, d, e, i = 0;for (a = 1; a <= 15; a++)for (b = 1; b <= 15; b++)for (c = 1; c <= 15; c++)for (d = 1; d <= 15; d++)for (e = 1; e <= 15; e++)if (b - a > 0 && c - b > 0 && d - c > 0 && e - d > 0){printf("A:%2d B:%2d C:%2d D:%2d E:%2d ", a, b, c, d, e);i++;if (i % 1 == 0)printf("\n");}printf("一共%d種\n", i);return 0;}把這一段代碼的運行結果輸出到,E盤上一個叫1.txt的文本文檔上。要求:1.用C語言。2,在我給的代碼的基礎上修改。
查看完整描述

1 回答

?
慕工程0101907

TA貢獻1887條經驗 獲得超5個贊

 // Q689426.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
    FILE *fpWrite=fopen("1.txt","w"); 
    int a, b, c, d, e, i = 0;
    for (a = 1; a <= 15; a++)
    for (b = 1; b <= 15; b++)
    for (c = 1; c <= 15; c++)
    for (d = 1; d <= 15; d++)
    for (e = 1; e <= 15; e++)
    if (b - a > 0 && c - b > 0 && d - c > 0 && e - d > 0)
    {
    printf("A:%2d B:%2d C:%2d D:%2d E:%2d ", a, b, c, d, e);
    fprintf(fpWrite, "A:%2d B:%2d C:%2d D:%2d E:%2d ", a, b, c, d, e);
    //如果要換行 fprintf(fpWrite, "A:%2d B:%2d C:%2d D:%2d E:%2d \n", a, b, c, d, e);
    i++;
    if (i % 1 == 0)
    printf("\n");
    }
    printf("total: %d\n", i);
    fprintf(fpWrite, "total: %d\n", i);
    fclose(fpWrite);
    return 0;
}

https://img1.sycdn.imooc.com//5b5ad0380001d8c100120017.jpg

查看完整回答
反對 回復 2018-07-27
  • 1 回答
  • 0 關注
  • 986 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號