-
C++ ~超難我不會
Posted on 二月 7th, 2010 1 comment1. 請宣告一個一維陣列(int),由使用者輸入10個數字,程式必須能夠找出最大值、最小值、平均值、標準差及從大排到小的輸出。以上程式需利用指標完成。
#include<iostream.h>
void main()
{
int*num=new int[10];
int temp,i=0;
cout<<"[請輸入10個數字]"<<endl;
while(i<10)
{
cout<<"數字"<<i+1<<">";
cin>>*(num+i);
i++;}
for(i=0;i<9;i++)
for(int j=i+1;j<10;j++)
{
if(*(num+i)<*(num+j))
{
temp=*(num+i);
*(num+i)=*(num+j);
*(num+j)=temp;
}
}
cout<<"[由大而小的順序是]";
for(i=0;i<10;i++)
cout<<*(num+i)<<’\t’;
cout<<endl;
delete [] num;
}我已打出大小排序了那如何分辨最大值跟最小值等等呢??
-
【重來】C程式的練習題 5【十萬火急】:
Posted on 二月 7th, 2010 1 comment關於這個C程式碼,怎麼修改內容,使他能輸入0~9整數任一個,假設為n,使程式印出0~n數字中任兩個數字的組合?
麻煩有說明,請用C語言的迴圈、陣列、函數…去修改它,但是不用C++!可以的話,麻煩給完整的程式碼!
#include<stdio.h>
int main(){
int i=0, j=0, a[10]={0,1,2,3,4,5,6,7,8,9}, k=0;//一開始變數宣告
printf("可能的組合:\n");//提示字元
for(i=0;i<10;i++)
for(j=i;j<9;j++){
printf("{%d,%d}\n", a[i], a[j+1]);//印出不同的組合
k++;
}printf("總共有%d種組合\n",k);
return 0;
} -
這個問題要給會的人來給答案
Posted on 二月 7th, 2010 1 comment~以亂數產生20天的氣溫資料(範圍從15℃~36℃),並且計算連續5天的平均溫度。其結果(資料檔)以檔案儲存!
其中裡面似乎是不能做出平均的數值或者有其他問題而不能執行
麻煩會的可以給一下詳細的解答ㄛ~謝囉!/* Fig. 5.9: fig05_09.c
Randomizing die-rolling program */
#include <stdlib.h>
#include <stdio.h>
#include <time.h>/* function main begins program execution */
int main()
{
srand(time(NULL));
int i; /* counter */
unsigned seed; /* number used to seed random number generator */seed; /* random number generator */
/* loop 10 times */
for ( i = 1; i <= 10; i++ ) {/* pick a random number from 1 to 6 and output it */
printf( "%10d", rand() % 22 + 15 );/* if counter is divisible by 5, begin a new line of output */
if ( i % 5 == 0 ) {
printf( "\n" );
} /* end if */} /* end for */
system("pause");
return 0; /* indicates successful termination */} /* end main */
/**************************************************************************
* (C) Copyright 1992-2004 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
*************************************************************************/ -
C++ ~很難我不會
Posted on 二月 6th, 2010 1 comment撰寫一個程式,並列出m~n之間的質數。其中m及n由使用者輸入。
可以用指數的話就用指數~
謝謝>< -
C程式的練習題 5【千萬火急】!
Posted on 二月 6th, 2010 1 commentWrite a C program to list all possible combinations of n characters out of the ten
characters ‘0’, ‘1’,…, ‘9’. That is, there are 45 combinations of two characters out of the
ten characters.還是一樣:要有說明、用函數或陣列或迴圈或其他,就是不用C++。
另練習題4也可用其他C程式寫法。
-
C程式的練習題 4【千萬火急】!
Posted on 二月 6th, 2010 2 commentsWrite a C program that reads one unsigned integer, reverses
the integer, and prints the reverse of the integer and the sum of the integer and its reverse.
For example, the reverse of 1234 is 4321 and the reverse of 120 is 21.先說一下,不用C++,要用C函數或陣列或迴圈,然後要有說明喔!
-
Visual C++的題目 急~~
Posted on 二月 5th, 2010 1 commentWrite a short C program that will print the quick brown fox
"jumps"
over
the lazy dog
to the computer screen. The first line of output should include the
quotation marks, and the second and third lines should be aligned by
three tab stops.
我有試著翻譯過了
不過翻譯出來好怪喔,還是不知道他要的是什麼東西>"<
麻煩高手幫我翻譯順便解答一下
感激不盡>< -
請問c語言程式作業急需><
Posted on 二月 5th, 2010 1 comment題目:Weite a small program to print the sum of the intergers between M and N, inclusie,where M and N are int integers.rite an M of 1 ad M of 100,your program should put 5050.
要用到Loop的技巧。 -
c++ 語法解釋
Posted on 二月 5th, 2010 1 comment3.輸入兩個正整數a, b請寫一個程式,計算這兩個正整數的最大公因數。
(提示:可利用輾轉相除法)
#include <iostream>
using namespace std;
int main()
{
int x,y,a;
cout << "x=";
cin >> x;
cout << "y=";
cin >> y;
a = x%y ;
while ( a>0 )
{
x = y;
y = a;
a = x%y ;
}
cout << y << endl ;system("pause");
}
我想請問的是while ( a>0 )
{
x = y;
y = a;
a = x%y ;
}
cout << y << endl ;system("pause");
}
這部份的意思是什麼? -
急~C++…..1個數學題目~e代表什麼意思~如何擺放
Posted on 二月 4th, 2010 1 commenta=2 , b=6, c=4, d=5, e=6
x=b的2次方減4ab分之d+1/2e
那個e是在2的旁邊~我想問C十十要如何表示這個例子
而那個e是什麼意思?
懂的人請解答~~謝謝

